Skip to content

Instantly share code, notes, and snippets.

@normansolutions
Created October 1, 2018 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save normansolutions/3609052ae35a51aa95cb5c5056f4e55f to your computer and use it in GitHub Desktop.
Save normansolutions/3609052ae35a51aa95cb5c5056f4e55f to your computer and use it in GitHub Desktop.
Import-Module ActiveDirectory
$ou = "OU=Office Computers,Dc=CompanyName,Dc=Net"
Get-ADComputer -Filter * -SearchBase $ou |
ForEach-Object {
Restart-Computer -ComputerName $_.name -force
}
# If you wish to eliminate specific machines from this restart - no problem, you can add a "where" clause using a wildcard to either target an individual or complete OU.
Get-ADComputer -Filter * -SearchBase $ou | where { ($_.DistinguishedName -notlike "*OU=Display,*" -and $_.DistinguishedName -notlike "*BURSAR*") } |
ForEach-Object {
Restart-Computer -ComputerName $_.name -force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment