Skip to main content

Posts

Create a backup using Robocopy

Creating a backup is a must if not a necessity for a SysAdmin job. Backup doesn't need to be complex or needs a very powerful software to do a backup. At the end of the day, whether it's a good commercial software creating a backup; what it does in the background is create another copy of the file or folders that needs to be backed up. So, for that reason a simple copy command with the existing tool in Windows can do a job also for some simple backup like logs or other files. Why need to backup the logs? In a security perspective and audit purposes, logs are very important. Of course, it will also depend on the contents of the log whether it is quite detailed or important data is captured like username, IP Address, time, files and folder being accessed and other data. Problems or issues may not be detected in real-time or issues maybe notice at a later time but the action that cause the issue happened some time ago as well, in which the only witness are the logs. A simple batch...

What application is running behind svchost.exe in Windows?

Task Manager can be opened in different ways via Taskbar, pressing Ctrl + Shift + Esc or right clicking on the Windows icon and selecting Task Manager. In Task Manager window, it will show what are the processes or services running on the system. On the Details Tab of the Task Manager the details of the .exe file or the applications or services running on the system will be displayed. One noticeable thing on Task Manager is the svchost.exe, depending on how busy the system is or how many applications, browsers or other items that will need to connect to svchost.exe. The said exe file can easily be seen on Task Manager since there will be few of them.   But what is the application running behind the svchost.exe? Or what is occupying or using svchost.exe? Why there are a few of them running on the system? To get to the bottom of all the questions above, PID or Process ID will show what is behind the svchost.exe. To do this, open an elevated CMD or command prompt window....

Close all open notepad instances or processes in one go

If you’re an admin and manually checking logs for details and opening each file one by one. Then opening multiple instances of notepad is quite an everyday task. Or you just love notepad in making notes, documentations or other endless reasons to use notepad. Then it will be a headache in closing all the notepad instances that were opened. However, PowerShell can be used to close all instances of notepad all at once. No sweat in clicking each file one by one. PowerShell can handle it in one click of a button if you open the file via PowerShell ISE. Here’s a simple PowerShell code snippet to close all files in one shot. #========== $x = ( Get-Process | Where-Object   { $_ . ProcessName -EQ 'Notepad' }) . count   1 .. $x | % {    stop-process -name notepad –force } #=========== Yes, 2 lines of code can save you a lot of time. The above code can be used also to close other processes that has multiple instances open on the system. If uns...

Ping sweep with Bash script in Linux

Ping is a good tool to easily check or troubleshoot a system whether it is online or not. Provided the system or device is allowed to reply to any ICMP request. A simple Bash script below shows how to ping a Class C subnet. Replace the IP Address range below if you want to use it depending on the IP Address set on your network. It also illustrates how to make use of while loop, increment a variable counter, and use a variable to substitute as part of the whole command in Bash.  #====================== #!/bin/sh i=0 while [ $i -ne 255 ]   # initialize the counter don't exit until 255 counter is reached do         i=$(($i+1))   #increment the variable counter by adding 1 to it         echo "$i"     # just show the counter as it is incremented         ping -c2 192.168.0.$i   # ping the IP Address twice $i will be substituted with ...

Excel VBA find last row with data

In Excel, ctrl + end will go to the last cell with a value. But this will be tricky if you have deleted the last row with a value or has deleted its contents on the cell. Since it will be recoded as the last cell that has a value or the user has inputted or type on that specific cell.   And Excel will still remember it as the last type cell with value. Pressing ctrl + end will still go there, thus provide the wrong result. However, to prevent this from happening you need to close the workbook and open it again. Then pressing ctrl + end will show the last row with value. But while the worksheet is active any last typed cell even though its content or deleted will be considered as the last row. Getting the last row with data even without closing the workbook can be done via this simple VBA code below. One caveat though, this will only search for the defined row within the VBA code and the number of rows to be checked has to be defined on the code also. So, type a numbe...

Unable to browse website or the internet

In today's digital world, browsing website is a must. And if unable to browse then it could be an issue especially if you need to get things done. You need a piece of code but unable to browse StackOverflow is quite terrifying for a person developing a simple program. Others don't care how things work, they just want to get things done and that's it. But if unable to browse a website there could be a lot of things involved. Here are some possible issues why unable to browse a site or the Internet. Of course the list below is just a small fraction of why unable to browse the Internet.   - Website or URL trying to browse is not available or server that host the website is down or offline - Website or URL is typed incorrectly on the address bar - Website is a non www URLs, example website is only http:\\thewebsite.com other than www.thewebsite.com - Website TLD or Top-Level Domain is incorrectly entered the site ends .net or .org .mil or other TLDs - Some website...

How to use regex in Linux Bash

Regex or regular expression uses a pattern that is compared to a string and will check if the pattern exists or the string matches the pattern. In Bash script a simple if then else and a regex pattern can be used to check if the pattern matches a set of input on a text file. Bash script below is a simple example on how to use regex in Bash using if then else. Script below uses this sample file "number_file.txt" with the sample text or contents shown below. a12567 b23567 c34568 12w678 23908 35107 23469 x1234 y3432 12094x 123y8 ==== #!/bin/sh patx="^[0-9]+$" while IFS= read -r line; do     echo "Text read from file: $line"     if [[ $line =~ $patx   ]]                then                  echo "Hey this one is alpahumeric --> $line."      else ...

PowerShell Ping IPV4 addresses

Ping a range of IPV4 and resolve its hostnames via PowerShell. Here’s a simple PowerShell code snippet to ping a range of an IPV4 addresses and any IP address that will reply will be shown as per the sample output below. #======================   ( 240 .. 254 | ForEach {     write $_     Test-Connection -computername "192.168.8. $_ "   -count 1 -erroraction 'silentlycontinue' | Format-Table -AutoSize   })   #====================== 240 .. 254 –- change this to a desired IP range from 1 to 254. 192.168.8. $_ -- change this IP Address on the IP Address configured or set on the network -count 1 –- ping 1 time -erroraction 'silentlycontinue' –- this will not display any errors on the screen if the IP Address can’t be found or is not set to reply to ICMP or ping protocol Format-Table -AutoSize –- if the device will reply with the hostname then the full name will be displayed on the screen and not trunca...