19 lines
430 B
PowerShell
19 lines
430 B
PowerShell
function Get-Uptime {
|
|
[CmdletBinding()]
|
|
[OutputType([string])]
|
|
param (
|
|
)
|
|
|
|
if (Test-IsWindowsPlatform) {
|
|
$now = Get-Date
|
|
$lastStartTime = (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime
|
|
|
|
$uptime = $now - $lastStartTime
|
|
|
|
return $uptime.ToString()
|
|
} else {
|
|
return "we clobbered the system uptime, doh"
|
|
}
|
|
}
|
|
|
|
Set-Alias -Name uptime -Value Get-Uptime |