Change CN attribute to match sAMAccountName (Full Version)

All Forums >> [Microsoft Exchange 2010] >> General


nicholashyer -> Change CN attribute to match sAMAccountName (17.Sep.2014 12:52:13 PM)

Recently I have made a change to the displayname for users so that they would be in the proper format of LastName, Firstname MIDINIT. This is the script I used to do it:

$Users = Get-User -ResultSize unlimited | where {$_.RecipientTypeDetails -eq "UserMailbox"}
ForEach ($User in $Users)
$DName = $User.LastName + ", " + $User.FirstName + " " + $user.Initials
$DName = $Dname.Trim()
Set-User $User -Name $DName -DisplayName $DName
Get-User $User | FT Name, DisplayName
$DName = $Null

When I ran this script apparently it changed the DN name on all these accounts and google docs sync stopped when all I really wanted to do was change the DisplayName field.

What I am looking for is a script to get the sAMAccountName property and then set it in the DN for my users to get the google sync working again. If I can set the DN back but keep the display name with the new change everything will work fine I think.



Page: [1]