Back to all recipes
Level: JuniorLast updated:
Move computers to a different OU
Get-ADComputer -Filter 'Name -like "LAB-*"' |
Move-ADObject -TargetPath "OU=Lab,OU=Workstations,DC=corp,DC=local" -WhatIfWhy it works this way
GPO applies by OU. A host left in the default Computers container never receives your policy.
Watch out
- Drop -WhatIf only after reviewing the list.
- After the move: gpupdate /force on the host, sometimes a reboot.