Skip to main content

Posts

Showing posts from 2021

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. C

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 unsure of what

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 the current number in the loop done # ======================= That's it, it will ping the IP Address twice. If the

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 number that is

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                  echo "Hey this one is a group of numbers --> $line."      fi done < number_file.txt === Above Bash script will check

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 truncated Sample Output: Ti

Office 365 Admin PowerShell basic commands

 Managing Office 365 via PowerShell CLI needs to have proper access rights or privileges.   First step is to connect to the Office 365 domain via an elevated PowerShell terminal. Connect-exchangeonline -userprincipalname email-admin@domain.com PowerShell for Office 365 is very handy. Below are just a few examples that might save some time and focus on other important task, or just simply enjoying more coffee time. Get or list aliases of a mailbox, email account or group mailboxes. Get-UnifiedGroup -Identity "Name of the Mailbox" | Select-Object DisplayName,@{Name=”EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_ -LIKE “SMTP:*”}}} | ft -wrap List the Primary Email of a group's mailbox using the group name. Get-UnifiedGroup -Identity "Name of the Mailbox"   | Select-Object DisplayName,PrimarySmtpAddress Change group primary email. Set-Unifiedgroup -identity "Group Name to change email" -primarysmtpaddress new-email@of-the

Linux get IP and Gateway and DNS subnet from CLI

In windows getting gateway, IP, subnet and DNS is quite straight forward using ipconfig command via command line.  ipconfig /all or ipconfig -all will show the settings of the IP Address, DNS IP, Subnet mask and Gateway. In Linux world, well it can also be done but need to remember a few command line to get all these settings. Here's how it's done from the command line or terminal. hostname -I;netstat -rn;cat /etc/resolv.conf So, it's hostname -I <--capital letter i and netstat -rn plus the resolv.conf file where the DNS IP Address is set. The ";" semi-colon is to execute the command line one after the other. hostname -I <-- will show the IP Address netstat -rn <-- will show the gateway and the subnet mask (need to install net tools if command is not found) /etc/resolv.conf <-- where the DNS IP Address is set It's quite daunting if you're a newbee, but hey it is just a command line it doesn't bite it just shows good information to know abo

Windows CLI get CPU Name, IP, OS, Mem and computer Name

One of the task of a Windows Admin is to know what OSes are running on his or her environment. Aside from checking what type of OSes are running, making sure also that CPU and Memory on users computers are suitable enough, so users can be productive. If the user doesn't have enough resources to run any software to do users tasks won't be  productive at all since and may end up consuming a lot of coffee than doing their work. :) So, as an IT Admin checking all these things will help to have a smooth operations. IP Address is the communication link of the device to the router, and the IP Address also links to the hostname or computer name and will be ultimately linked also to the logged in user. Example, deploying a specific software to a single user. IP Address must be known  in advanced or else the software being deployed might end up in someone else computer and can be disastrous if the license will be tied automatically to the hostname or IP Address.  WMIC command below, will

Check Windows version Home or Pro via command line

How to check Windows if it is a Home or Pro version? WMIC a command line tool that is able to check the Windows version, build number and also shows whether the OS is a Pro or Home version. In an AD environment having a Home version of Windows is not a good idea as the OS isn't able to join a domain. Here's the WMIC command line to check. Open the command line window by pressing windows key + r, and type: cmd then press enter A new window will appear and type this command line: wmic os get BuildNumber, Version, Caption  After typing the command line and pressing enter  key, it will show a similar output like the image below: It will display, BuildNumber, Caption which will show whether the OS is home or pro, and the Version of the OS. That's it, WMIC is a great tool. Cheers. Till next time. Stay safe! and keep things up! ================================ Free Android Apps: Click  links below to find out more: Excel Keyboard guide: https://play.google.com/store/apps/details?i

How to disable Firefox Auto-Update

Not installing any updates is not a good idea at all. Since the software/device will be vulnerable for any security issues. However, disabling update and installing it later is another story. Of course, updates should be installed as promptly as possible especially if it is a critical update. Mozilla Firefox has an auto-update feature, this feature though is customizable you can disable auto-update and enable later if you need to install updates. How to disable and enable auto-update in Mozilla Firefox? For Windows OS 64 bit, open an elevated command prompt. Elevated command prompt or admin command prompt is needed when modifying features that requires admin access. At the elevated command prompt, browse or change directory to where Mozilla is installed. Default location would  be: C:\Program Files\Mozilla Firefox Search for mozilla.cfg, and open it with your preferred text editor. Or simply type: notepad mozilla.cfg this will open the config file. Depending on what has been set in you

Windows release DHCP IP Address and get a new one

 Working remotely is quite a norm in today's pandemic world.  IT / System Admin working remotely may find it difficult or a good opportunity to work at the comfort at their own homes. Difficult in a way, when something goes wrong on a server or any device and you need a physical hand even just to force power off and turn it back on may seem an impossible task. DHCP is an amazing technology that lets machines auto configured themselves with an IP Address without human intervention. But not everything seems to work smoothly at times, and if you have multiple networks in a single manage switch. Changing one network from another makes life easier using a manage switch. However, the machine, server or computer may not change easily; you either need to reboot the machine or just simply release and renew the DHCP to set or get the desired IP Address from a new network profile. In Windows DHCP network, ipconfig /release will release the IP and the machine will be automaticall

No bootable medium found error VirtualBox

Migrating from physical to virtual or P2V is a common thing to do. In this virtualization era. If hardware or a server is showing some issues, like rebooting by itself when no changes are made and the server is at the age of a primary 3 kid. Then this could be that the server is showing some signs that it needs to be retired. P2V is a good option if an existing powerful server that is not fully utilized and is able to handle another load. Migrating from OpenStack or exporting OpenStack VM to a volume so it can be used outside of OpenStack is another practice also. But sometimes things don’t go smoothly and few bumps or issues here and there may arise at times. For example doing P2V in VirtualBox for a Linux system shows an error, “FATAL: No bootable medium found! System halted.” And you let the VM run for hours hoping that it will just boot by itself but it won’t just budge the error persist no matter how long you wait. P2V is migrating or cloning a physical server to a virtu