![]() $Bootuptime = (Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName $server).LastBootUpTime To check the uptime on the remote computers, use - ComputerName parameter in the command. Write-Output "Server Uptime -> Days: $($uptime.days), Hours: $($uptime.Hours), Minutes:$($uptime.Minutes)" Output Server Uptime -> Days: 6, Hours: 0, Minutes:17 $bootuptime = (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTimeįrom the Output, we can say that the server is up from 6 Days and 17 minutes. So we will compare the difference between the current date/time with the Bootup date/time. ![]() We need now the uptime of the system in Days- Hours- Minutes format. (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime.Gettype() Output IsPublic IsSerial Name BaseType If we check the datatype of the above output, it should be DateTime because of the output format. Example Get-CimInstance -ClassName Win32_OperatingSystem | Select LastBootUpTime Output LastBootUpTime Once you use the mentioned class there is a property called LastBootupTime which shows the date when the computer is last rebooted. To get the Windows System uptime with PowerShell, we can use the CIM Instance method with class name Win32_OperatingSystem.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |