Author Posts

July 13, 2017 at 7:36 am

Hi All

not something ive really needed to do before however i need to rename the (Name) displayed in ADUAC, managed to find the correct CMDLETs however i dont just want to press the button, would like to try on a few to test first. -Whatif is fine but i cant see what the name changed to / if it changed correctly.

so i would like to select the first 3 users in $users rename those and check

$users = get-aduser -Filter * -SearchBase “OU=Users,OU=kuala Lumpur,OU=Malaysia,OU=Australasia,DC=global,DC=Domain,DC=com” -SearchScope Subtree -Properties displayname 

foreach ($user in $users)
    Rename-ADObject $user.DistinguishedName -NewName $user.displayname -WhatIf

July 13, 2017 at 9:14 am

Pipe get ad users to select -first 3:

 get-aduser -filter * | select -first 3

July 13, 2017 at 9:43 am

Thanks Ben, nice and simple 🙂

July 13, 2017 at 12:00 pm

No worries! Glad it helped you.

July 13, 2017 at 12:58 pm

Although querying ALL users just for the first three that happen to come back is pretty brutal on the domain controller, from a performance perspective.

July 13, 2017 at 1:34 pm

Should be alright.

July 14, 2017 at 12:32 pm

hey Don

i thought with "searchbase" it would only query the objects within scope ?

July 14, 2017 at 3:08 pm





July 14, 2017 at 4:10 pm

You still need to assign $Users though. :/

July 16, 2017 at 8:27 pm

(get-aduser -filter * )[0..2]

July 17, 2017 at 12:09 am

I can't test it right this second, but I think -ResultSetSize 3 would limit the query to just the first three found. That should reduce any pounding on the DC before it even starts.

July 17, 2017 at 9:50 am

Yep -ResultSetSize 3 also works 🙂