Move bulk computers to OU

  • 156 Views
  • Last Post 12 February 2017
yogeshcittu posted this 12 February 2017

Hi All,
I'm using below script to move bulk computers to a OU. But while executing this script I'm receiving an error.Anyone who can help me
$COMPUTERS = get-content c:\Temp\Computers.txt$COMPUTERS|Foreach{Get-ADComputer $_ | Move-ADObject -TargetPath "OU=TARGETOU,DC=..."}
Move-ADObject : The operation could not be performed because the object's parent is either uninstantiated or deleted
Note:Above script doesn't work only when I specify target OU in a nested OU
Regards,Yogesh

Order By: Standard | Newest | Votes
MATTNY posted this 12 February 2017

If the OU hierarchy is General OU nested inside Computer OU nested inside Location OU, then the DN of your Target OU would be: OU=General,OU=Computer,OU=Location,dc=contoso,dc=com 

show

yogeshcittu posted this 12 February 2017

HI Matt,
Thanks for that!!.
When you look at the above script,So where do I specify parent ou and target OU
For example
Parent ou: ou=Location,DC=contoso,DC=com"
Target ou: ou=General,ou=Computer,DC=contoso,DC=com"
Could you mention how the whole script will look like.
Regards,Yogesh

show

MATTNY posted this 12 February 2017

Yogesh,If the target OU is nested, the DN must contain its parent OU; OU=TargetOU,OU=ParentOU, dc=domain,dc=domainsuffix matt  

show

Close