A simple PS command to get a system’s LastBootUpTime using PowerShell.
# Local Computer
Get-CimInstance -Namespace root\cimv2 -ClassName Win32_OperatingSystem | Select LastBootUpTime
Use the following for getting LastBootUpTime for a remote system.
# Remote Computer
Get-CimInstance -ComputerName <systemName> -Namespace root\cimv2 -ClassName Win32_OperatingSystem | Select LastBootUpTime
$Computers = Get-Content -Path .\computers.txt
forEach ($Computer in $Computers) {
$LastBoot = Get-CimInstance -ComputerName $Computer -Namespace root\cimv2 -ClassName Win32_OperatingSystem | Select LastBootUpTime
Write-Host "$Computer`t$($LastBoot.LastBootupTime)"
}
1 thought on “Get the Last Boot Time Using PowerShell”