PowerShell
Uptime

Uptime

A small PowerShell script to check the uptime of a computer over the network.

$ComputerName = "MACHINENAME"

$userSystem = Get-WmiObject win32_operatingsystem -ComputerName $ComputerName -ErrorAction SilentlyContinue 

if ($userSystem.LastBootUpTime) { 
$sysuptime= (Get-Date) - $userSystem.ConvertToDateTime($userSystem.LastBootUpTime) Write-Output ("Last boot: " + $userSystem.ConvertToDateTime($userSystem.LastBootUpTime) ) Write-Output ("Uptime : " + $sysuptime.Days + " Days " + $sysuptime.Hours + " Hours " + $sysuptime.Minutes + " Minutes" ) 
}
else { 
Write-Warning "Unable to connect to $computername" 
}

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments