Jump to content
Pulseway 9.14 🔥

Featured Replies

Posted

Wrote this script with the help of Support. Thanks Ermins!

$days = 35
$system = Get-WmiObject win32_operatingsystem

if($system.ConvertToDateTime($system.LastBootUpTime) -lt (Get-Date).AddDays(-$days)){
    Restart-Computer -Force
}else{
    Write-Host "Machine was rebooted less than $days days ago"

}

  • Administrators

All machines that reboot will timeout the script execution. So when you look at the task execution you will see it running for an hour if you don't stop it. The machines that reboot will show up as failed in the task execution results view.

-Paul

Create an account or sign in to comment