ps/Modules/Cole.PowerShell.Developer/Public/Get-Uptime.ps1

19 lines
430 B
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
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