Windows Server

Using CMD & PowerShell to Find Last Boot Time Remotely

Here is a simple and short command that will help you tell the last boot time.

CMD:

SystemInfo /S $Server | find /i "Boot Time"

Powershell Script:

$Server = Read-Host -Prompt 'Input the server name'
SystemInfo /S $Server | find /i "Boot Time" > C:\Users\$env:username\Desktop\Last_Boot-$Server.txt

The above Powershell script will pop up and prompt you for the server name and then export it to your desktop.
You can modify the above Powershell script to run on startup or a scheduled task and save to another location.

Here is another script you can check which is bit faster:

$Server = Read-Host -Prompt 'Input the server name'
Get-CimInstance -ComputerName $Server -ClassName win32_operatingsystem | select csname, lastbootuptime | out-file $env:USERPROFILE\Desktop\Last_Boot-$Server.txt

-ComputerName accepts an array, so you can hit multiple servers at the same time and export to the same text file.

Leave a Reply

Your email address will not be published. Required fields are marked *