• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

Changing OU name using powershell

trying to rename an organisational unit using the follow code in powershell:

rename-adobject -identity "OU=Users,OU=koopus,DC=qessar,DC=com" -newname "klipsy"

but it throws back this error:
rename-adobject : Directory object not found
At line:1 char:1
+ rename-adobject -identity "CN=Users,OU=koopus,DC=qessar,DC=com" -newname "klipsy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (CN=Users,OU=koopus,DC=qessar,DC=com:ADObject) [Rename-ADObject], ADIden
   tityNotFoundException
    + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,M
   icrosoft.ActiveDirectory.Management.Commands.RenameADObject
0
Ikky786
Asked:
Ikky786
1 Solution
 
Miguel Angel Perez MuñozCommented:
Appears powershell can not read thos OU, maybe it is not correctly write or has not enough privileges to read it.
0
 
RizzleCommented:
Have you ran this from a domain controller whilst being logged in as an administrator? did you run Powershell as administrator when doing this?
0
 
Joshua GrantomSenior EngineerCommented:
Are you trying to rename the User folder to "klipsy" or do you mean to rename "koopus" to "klipsy" ?
0
 
Michael Ian ClaridgeActing Service Delivery ManagerCommented:
Hello,

The User container in AD has a flag set specifically so it cannot be changed. (It is not an OU).
However if you want to rename the OU "koopus", sometimes typing the DN letter perfect cannot find the OU...very bizarre but you can search for the OU first and then pipe it as below.

Please do not forget to assign points once you have an answer.

Get-ADObject -filter {ObjectClass -eq "OrganizationalUnit"} | where {$_.DistinguishedName -eq "OU=koopus,DC=qessar,DC=com"} | Rename-ADObject -NewName "klipsy"

Open in new window

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now