Solved

Changing OU name using powershell

Posted on 2014-10-13
4
199 Views
Last Modified: 2014-11-20
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
Comment
Question by:Ikky786
4 Comments
 
LVL 19

Expert Comment

by:Miguel Angel Perez Muñoz
Comment Utility
Appears powershell can not read thos OU, maybe it is not correctly write or has not enough privileges to read it.
0
 
LVL 13

Expert Comment

by:Rizzle
Comment Utility
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
 
LVL 16

Expert Comment

by:Joshua Grantom
Comment Utility
Are you trying to rename the User folder to "klipsy" or do you mean to rename "koopus" to "klipsy" ?
0
 
LVL 10

Accepted Solution

by:
Michael Ian Claridge earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now