Adventures in Renaming AD Objects - Microsoft Word

Adventures in Renaming AD Objects

Published 3 min read

Windows Server Active Directory Users and Computers management console

As you’re well aware I’m definitely an AD person. Sure, with such a complex system it’s just a matter of time until you go insane, but for the most part it’s a reliable, widespread directory management solution. Recently I’ve been tasked with creating a bunch of users in an AD environment and having their “name” attribute be their full name (mostly for aesthetic reasons).

When I created the user objects with PowerShell, the common name (or CN for short) was the user’s login (Well, technically it’s the SamAccountName which initializes with the value from the name attribute).

Sidenote: This isn’t the only way or intended behavior, but I made a mistake and had to fix it :)

So after I created a bunch of users with PowerShell it looked something like this:

Renaming AD Objects
Renaming AD Objects

When you created a user directly through ADUC though, their “name” attribute was their full name, which was dynamically created as I typed in the user’s first and last name (And initials, if applicable).

Let’s look at my own user object, that I created via PowerShell’s New-ADUser command.

Renaming AD Objects
Renaming AD Objects

You can see that my common name is indeed o.fichman in the first section of the DistinguishedName attribute, the Name attribute, and the SamAccountName attribute. We’ll ignore the UserPrincipalName for now because even though it’s the same, I have put a specific custom suffix on it.

So I created these users, this wasn’t the intended outcome and I’d like to rename them. One way I could go about doing this is editing the user object’s name attribute with the Set-ADUser cmdlet

Renaming AD Objects
Renaming AD Objects

Hmm… I can’t really find the attribute I’m looking for, maybe I’ll just use the replace option.

Renaming AD Objects
Renaming AD Objects

Well, that didn’t go so well.

After digging around for a while I decided to give Rename-ADObject a try.

Renaming AD Objects
Renaming AD Objects

Lo and behold! It worked!

Let’s create another Lava Monster! (The following command will create a user in the default location, which is “CN=Users,DC=<YourDomain_Part1>,DC=<YourDomain_Part2>”)

Renaming AD Objects
Renaming AD Objects

As you can see I now have 2 users with the name “Lava Monster”. That’s great! What if I try to create another one in the default location?

Renaming AD Objects
Renaming AD Objects

Why does this happen?

Well, in Active Directory, there are 3 attributes related to a user’s authentication for which uniqueness is enforced, but not all 3 were created equal, as this uniqueness is enforced in different levels of the directory.

The name attribute is one of them. This attribute must be unique in the container because if it wouldn’t be, we’d have 2 objects with the same distinguishedName (LDAP path).

The other 2 attributes are:

samAccountName - must be unique in the domain
userPrincipalName - must be unique in the forest

To summarize: Renaming object with PowerShell (and in general, perhaps) is not as straightforward as one might think. I hope you found this post informative and I hope it will save you some unnecessary headache and hassle.

Microsoft Word

Do you want to save the changes you made to Adventures in Renaming AD Objects?

Microsoft Word

Find and Replace
Insert Hyperlink
Adventures in Renaming AD Objects Properties
Title:
Adventures in Renaming AD Objects
Subject:
Learn how to rename Active Directory user objects using PowerShell's Rename-ADObject cmdlet when Set-ADUser falls short.
Author:
Orel Fichman
Category:
Active Directory, Microsoft, PowerShell
Keywords:
Active Directory, Microsoft, PowerShell
Created:
June 18, 2020
Modified:
June 18, 2020
Words:
498 (3 min read)
Location:
/blog/adventures-in-renaming-ad-objects/
Word Count
Font
Preview

The quick brown fox jumps over the lazy dog.

Changes the reading font of documents on this site. Saved for your next visit.

Accessibility Options
Text size
100%
Display
WordArt Gallery

Select a WordArt style for the title on the home page:

About Microsoft Word

Microsoft® Word 97 (not really)

This is hugo-word97, a Hugo theme that dresses a blog up as a 1997 word processor. It is a fan homage, not affiliated with or endorsed by Microsoft.

This product is licensed to:
Orel Fichman
orelfichman.com


Built with Hugo 0.147.7 on November 16, 2026. No backend, no frameworks, about as much JavaScript as Word 97 had RAM.