Notifications
Clear all

Uptime

1 Posts
1 Users
0 Reactions
23 Views
Frank Schroeder
(@iseetwizard)
Estimable Member Admin
Joined: 5 years ago
Posts: 64
Topic starter  

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" 
}

 


   
Quote