Jump to content

Recommended Posts

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
Posted

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

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...