Select Page

Required Files: None


Powershell to alert you if a machine hasn’t been rebooted lately


 

Import-Module $env:SyncroModule
 
$LastRebootTime = Get-WmiObject win32_operatingsystem | 
select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
 
$Today = Get-Date
$DiffDays = $Today.Date - $LastRebootTime.LastBootUpTime.Date
 
Write-Host "Days since boot: $($DiffDays.TotalDays)" 
 
 
if($DiffDays.TotalDays > 30){
 Rmm-Alert -Category "uptime_trigger" -Body "This machine has been online too long!"  
}