diff --git a/Restart-EndpointOnUptime.ps1 b/Restart-EndpointOnUptime.ps1 index 670cd20..7813987 100644 --- a/Restart-EndpointOnUptime.ps1 +++ b/Restart-EndpointOnUptime.ps1 @@ -5,7 +5,7 @@ Function Restart-EndpointOnUptime ([int]$MaxUptimeHours) { $LastBootUpTime = Get-WmiObject -Class Win32_OperatingSystem1 -ErrorAction Stop | Select-Object -ExpandProperty LastBootUpTime $LastBootUpTime = [Management.ManagementDateTimeConverter]::ToDateTime($LastBootUpTime) } - Catch { Write-Error $_.Exception.Message ; Write-Output "Cannot restart this computer" ; Exit } + Catch [Exception] { Write-Error $_.Exception.Message ; Write-Output "Cannot restart this computer" ; Exit } # Calculate the difference in hours