Add PowerShell Get-Uptime function

This commit is contained in:
Anthony Rose 2024-03-08 14:09:35 +00:00
parent 4d23b17710
commit d087e6d040

View file

@ -72,6 +72,12 @@ if ($IsWindows -or ($env:OS -eq "Windows_NT")) {
$env:__COMPAT_LAYER = "RunAsInvoker"
}
if (!(Get-Command Get-Uptime -ErrorAction SilentlyContinue)) {
function Get-Uptime {
Get-WmiObject Win32_OperatingSystem | Select-Object @{LABEL='LastBootUpTime';EXPRESSION={$_.ConvertToDateTime($_.LastBootUpTime)}}
}
}
# Force UTF-8 output.
$OutputEncoding = [System.Text.Encoding]::UTF8