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