this is not the way...
This commit is contained in:
@@ -2,7 +2,7 @@ Function Restart-EndpointOnUptime ([int]$MaxUptimeHours) {
|
|||||||
|
|
||||||
# Check the last boot up time
|
# Check the last boot up time
|
||||||
Try {
|
Try {
|
||||||
$LastBootUpTime = Get-WmiObject -Class Win32_OperatingSystem1 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty LastBootUpTime
|
$LastBootUpTime = Get-WmiObject -Class Win32_OperatingSystem1 -ErrorAction Stop | Select-Object -ExpandProperty LastBootUpTime
|
||||||
$LastBootUpTime = [Management.ManagementDateTimeConverter]::ToDateTime($LastBootUpTime)
|
$LastBootUpTime = [Management.ManagementDateTimeConverter]::ToDateTime($LastBootUpTime)
|
||||||
}
|
}
|
||||||
Catch { Write-Error $_.Exception.Message ; Write-Output "Cannot restart this computer" ; Exit }
|
Catch { Write-Error $_.Exception.Message ; Write-Output "Cannot restart this computer" ; Exit }
|
||||||
|
|||||||
Reference in New Issue
Block a user