Alex
asked on
Limit script to only reboot 20 machines at a time
Good morning,
Right, so this works fine, it enumerates the machines with the correct names from the specified OU.
How can I make it limit the reboot to 20 and wait 20 seconds until each machine is back up?
Thanks
Alex
$Computers = Get-ADComputer -Filter * -searchbase "OU=branch,DC=net,DC=Company,DC=co,DC=uk" | Where-Object {$_.Name -like "*TM*"} | Select -Property Name
ForEach ($Computer in $Computers) {
If (Test-Connection -ComputerName $Computer -Quiet) {
& shutdown.exe -m "\\$($Computer)" /f /R
} Else {
"$($Computer) is not online" | Out-File -Append "C:\Powershell Projects\reboot script\computersnotonline.txt"
}
}
Right, so this works fine, it enumerates the machines with the correct names from the specified OU.
How can I make it limit the reboot to 20 and wait 20 seconds until each machine is back up?
Thanks
Alex
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER