mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-21 17:38:19 +02:00
Updated check-uptime.ps1
This commit is contained in:
parent
a8bafada38
commit
7229b3d980
@ -44,11 +44,11 @@ try {
|
|||||||
$uptime = New-TimeSpan -Start $lastBootTime -End (Get-Date)
|
$uptime = New-TimeSpan -Start $lastBootTime -End (Get-Date)
|
||||||
}
|
}
|
||||||
$status = "✅"
|
$status = "✅"
|
||||||
$pending = "No pending reboot"
|
$pending = ""
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
if (Test-Path "/var/run/reboot-required") {
|
if (Test-Path "/var/run/reboot-required") {
|
||||||
$status = "⚠️ "
|
$status = "⚠️ "
|
||||||
$pending = "Pending reboot (found: /var/run/reboot-required)"
|
$pending = "with pending reboot (found /var/run/reboot-required)"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$reason = ""
|
$reason = ""
|
||||||
@ -84,10 +84,10 @@ try {
|
|||||||
}
|
}
|
||||||
if ($reason -ne "") {
|
if ($reason -ne "") {
|
||||||
$status = "⚠️ "
|
$status = "⚠️ "
|
||||||
$pending = "Pending reboot (registry got $($reason.substring(2)))"
|
$pending = "with pending reboot (registry got $($reason.substring(2)))"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Host "$status $(hostname) is up for $(TimeSpanAsString $uptime) since $($lastBootTime.ToShortDateString()) - $pending"
|
Write-Host "$status $(hostname) is up for $(TimeSpanAsString $uptime) since $($lastBootTime.ToShortDateString()) $pending"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user