Category: Scripts

Title
Showing 1 - 1 of 1
Listing Description

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

 


Categories