# First, let’s perform and search query to retrieve OU list on local domain;

Get-QADObject -Name testou* -sizelimit 0 | ft name

Name

—-

testou1

testou2

testou3

 

# You can also define a specific OU to target a specific location;

Get-QADObject -name testou* -searchscope “onelevel” -searchroot “ou=Groups,ou=global,dc=mydomain,dc=net” -sizelimit 0

 

# for SUBTREE;

Get-QADObject -name testou* -searchscope “subtree” -searchroot “ou=Groups,ou=global,dc=mydomain,dc=net” -sizelimit 0

Name                           Type            DN

—-                           —-            —

testou1                        organization… OU=testou1,OU=RoleBased,OU=Groups,OU=Global,DC=mydomain,DC=net

testou2                        organization… OU=testou2,OU=RoleBased,OU=Groups,OU=Global,DC=mydomain,DC=net

testou3                        organization… OU=testou3,OU=RoleBased,OU=Groups,OU=Global,DC=mydomain,DC=net

 

 

 

# To rename multiple OUs:

Get-QADObject -name testou* -searchscope “subtree” -searchroot “ou=Groups,ou=global,dc=mydomain,dc=net” -sizelimit 0| Foreach {Rename-QADObject $_ -newName (“NEW-” + $_.name)}

 

Name                           Type            DN

—-                           —-            —

NEW-testou1                    organization… ou=NEW-testou1,OU=RoleBased,OU=Groups,OU=Global,DC=mydomain,DC=net

NEW-testou2                    organization… ou=NEW-testou2,OU=RoleBased,OU=Groups,OU=Global,DC=mydomain,DC=net

NEW-testou3                    organization… ou=NEW-testou3,OU=RoleBased,OU=Groups,OU=Global,DC=mydomain,DC=net

Note : there is no impact to rename an OU, even if the « prevent from accidental deletion check box » is enabled !!!

Use ADSIEDIT to check if all the attributes have been correctly updated.