Skip to main content

Posts

Recent posts

PowerShell execute multiple task on different servers

If you find yourself feeling overwhelmed by the maintenance of hundreds or multiple servers, there is no need for concern; PowerShell can assist you, provided that you have a clear understanding of the required actions. Below is a PowerShell code snippet that can shut down a server, restart a server, restart a service, or stop a service. It is advisable not to attempt this in a production environment unless the necessary actions are permissible and the task has been approve. An example image illustrating the output of the PowerShell script is included below. Ensure to modify the server name or service name as appropriate. And most importantly, used an elevated PowerShell with Admin credentials. Here's the PowerShell code: $servers = @("Admin_server", "DB_Server", "Redis_Server", "Docker_server") $action = @("Shutdown_server", "Restart_server", "Service_restart", "Service_stop") $ix = 0 ...

Linux: Displays Interface Status in Up or Down State

The `ip link show` command, available in more recent versions of Linux that support the `ip` command, provides information about network interfaces and their respective states. Executing `ip link show` yields extensive details regarding the interface, including its MAC address, operational state, IP address, and additional relevant information. The command below identifies the names of interfaces currently in either an UP or DOWN state. The output is piped to `grep` to filter and display only the state alongside the interface name. To display interfaces in a DOWN state, use the following command: ```ip command: echo "Interface on DOWN state: $(ip link show | grep "state DOWN" | grep -oP '^[0-9]+:\s+\K\S+' | cut -d: -f1)" ``` To display interfaces in an UP state, the command is: ```ip command: echo "Interface on UP state: $(ip link show | grep "state UP" | grep -oP '^[0-9]+:\s+\K\S+' | cut -d: -f1)" ``` The follo...

Windows 10/11: "This PC" in Windows Explorer is not displaying or missing

In Windows 10/11 the "This PC" icon, previously known as "My Computer" during the era of Windows XP, may unexpectedly vanish when accessing Windows Explorer or File Explorer. Microsoft has included a feature that allows users to either display or hide the "This PC" icon within the Navigation Pane. To control the visibility of the "This PC" icon, users should open File or Windows Explorer, navigate to the "View" dropdown menu, select "Show," and then click on "Navigation Pane." By default, the "Navigation Pane" option is enabled. If this option is disabled, the "This PC" icon will not be visible in File or Windows Explorer. In summary, if the "Navigation Pane" is enabled, "This PC" will be accessible; conversely, if it is disabled, "This PC" will not be displayed. Please follow image below on how to do it. Open File Explorer or Windows Explorer by pressing ...

How to select single click or double click to open a folders in Windows

How to change settings in Windows to single or double click to open folders or items in Windows 11 or Windows 10? The default in Windows is you need to double click on opening folders or files. However, an option is given on the system to change it to single click. Images below shows how to change the settings to single click or double click when opening items or folders in Windows. Open Windows Explorer by pressing "Windows key + E" or simply right click the Windows icon the four squares on the task bar and choose "File Explorer". Once the "File Explorer" opens click or select the "3 dots ..." on the bread crumbs bar or whatever its called. Please see image below on which one to click. After clicking the "3 dots" select "options" from the drop down menu that will appear on the screen. Please see image below for the guide. After selecting or clicking the "options" button, a Window will appear where you ...

PowerShell: Displaying Local Administrator Accounts

The PowerShell command provided below will enumerate all local accounts that belong to the Administrator group or possess administrative privileges on the system. Here is the PowerShell code to execute: Get-CimInstance Win32_GroupUser | Where-Object {$_.GroupComponent.Name -eq "Administrators"} | Select-Object -ExpandProperty PartComponent | Select-Object -Property Name Example Output: There are other ways to list user accounts with administrator privileges on a Windows System. On a server OS or other OS that supports Microsoft Management Console command will also show the list of users with admin rights, press "windows key + r" and when run box appears type: "lusrmgr.msc" or simply open a command prompt and type the command: "lusrmgr.msc", if the command is supported it will show a window where you can check the list of users with admin access. The MMC is beneficial because it features a graphical interface, but using scripts proves...

PowerShell to Verify BIOS Information

The BIOS Properties contain a wealth of information, with BIOS standing for Basic Input Output System. In technical point of view, a computer cannot start without the BIOS. While the computer may power on, it will only show a blank screen, and the operating system will not load or function or there will be no display. Here’s a straightforward PowerShell script to check details such as the BIOS release date, computer serial number, BIOS version, and additional information. PowerShell script to get BIOS information or data. $biosProperties = Get-WmiObject Win32_BIOS Write-Host "BIOS Name:" $biosProperties.Name Write-Host "BIOS Serial Num:" $biosProperties.serialnumber Write-Host "PrimaryBIOS:" $biosProperties.PrimaryBIOS Write-Host "BIOS ReleaseDate:" $biosProperties.ReleaseDate Write-Host "BIOS Version:" $biosProperties.BIOSVersion Write-Host "BIOS Caption:" $biosProperties.Caption Write-Host "BIOS Language...

PowerShell Get ComputerName

Getting computername in PowerShell is quite straight forward using environments variable. Example: $computerName = $env:ComputerName Write-Host "The computer name is: $computerName" With the right credentials and as long as WinRM or Windows Remote Management is enabled we can use the Environment ComputerName variable to shutdown a remote PC. This command runs or shutdown a remote pc, by invoking a local command to shutdown the PC. Invoke-Command -ComputerName remote_computer_name -ScriptBlock {Stop-Computer -ComputerName $env:ComputerName } The above invokes shutdown command locally, just like you were in front of the server or computer. Above is just a demonstration on how to use ComputerName environment variable. Shutting down a remote computer with a valid domain credentials, doesn't need the invoke-command instead command below can be used. Stop-Computer -ComputerName "RemotePC1", "Server2" -Force 1 Peter 5:6: "Humble y...