Link to home
Start Free TrialLog in
Avatar of Jaber MM
Jaber MM

asked on

script to move computer from default OU to named OU

hi all,

any one can have any idea how to move computer from default OU to named OU using power shell command .

for example UComputer is the new OU

mostly the script will work on the first letter of the computer name i.e. U for Ucomputer Container , M for MComputer Container

appreciate your help and support .
Avatar of Patrick Bogers
Patrick Bogers
Flag of Netherlands image

get-adcomputer computerName | Move-ADObject -TargetPath ‘ou=Ucomputer,dc=domain,dc=net’

Cheers
Avatar of Jaber MM
Jaber MM

ASKER

@Patrick Bogers

thanks for your fast reply , so i need to have three of this for each OU

get-adcomputer computerName | Move-ADObject -TargetPath ‘ou=Ucomputer,dc=domain,dc=net’

where i can put the computer name to specify that it is start with a C or M letter

according to what i understand this script will move the computer based on the full name and what i need to move based on first letter

thanks
Get-ADComputer -Filter {name -like "C*"}

Run this to test if it is desired return. If so append
| Move-ADObject -TargetPath ‘ou=Ucomputer,dc=domain,dc=net’     To it.
Just curious, why not just permanently redirect
redircmp.exe "OU=Our Computers,DC=Domain,DC=com"

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Full solution provided.

https:#a42095427 doesn't move from the default Computer container, and it doesn't support the required "move multiple computers to different OUs based on their names" mapping.

@Shaun:
that won't work in this case, because the target OU needs to be determined dynamically based on the computer name.