petben Posted November 10, 2014 Posted November 10, 2014 if a member of staff gets married amd changes their name, in the past (exchange 2010) i deleted their AD account (which disconnected their mailbox), create a new account (without a mailbox) and then in Exchange connect the orphaned mailbox to the new user. What is the process for this in Office365, it only looks like you can connect to the same user, if they were deleted and reinstated or something. Thanks for any ideas.
Boredguy Posted November 10, 2014 Posted November 10, 2014 I rename their AD account from their maiden name, and also update the e-mail address field (plus add a proxy so the old address will still receive mail) Force a sync to 365 Connect via Powershell and then run Set-MsolUserPrincipalName -UserPrincipalName [email protected] -NewUserPrincipalName [email protected] to change the logon name. All the e-mail stays in the account, and they carry on as normal but just authenticate with their new details.
petben Posted November 18, 2014 Author Posted November 18, 2014 I have written my script that changes all the AD values and proxyAddress attributes. In the users AD they have several email addreess including a value of new[email protected] (this is correct) run dirsync In O365 they have all the correct proxy addresses from AD but old[email protected] (and no entry for new[email protected] any ideas thanks?
Boredguy Posted November 18, 2014 Posted November 18, 2014 Have you made sure that the mail field in AD is set to the [email protected] (or whatever domain name you are using) as this is the critical value
petben Posted November 18, 2014 Author Posted November 18, 2014 I've gone through the 'attributes' tab of the AD user and there is no entry anywhere for oldusername@onmicrosoft domain.
petben Posted November 19, 2014 Author Posted November 19, 2014 boredguy, can you take a look at a user who you have performed this username change on, do they have all the correct email addresses in their msonline 365 asccount. no entries for [email protected]? thanks
Boredguy Posted November 19, 2014 Posted November 19, 2014 We are using school.county.sch.uk as our domain name, so for my last member of staff who got married these are the details. In ActiveDirectory, User HooperX has - mail field set as [email protected] - proxyaddress set SMTP:[email protected] & smtp:[email protected] - userPrincipalName set as [email protected] In Office 365 *after* updating the e-mail account login name they have the following addresses shown - Primary Username is [email protected] - Other e-mail addresses are [email protected] and [email protected] As we only use our full school domain for 365, I do not worry about updating the onmicrosoft.com address as we have never publicised it to users. I guess I could update the value at the same time as settings the login account from [email protected] to [email protected]
petben Posted November 19, 2014 Author Posted November 19, 2014 Ok, so you have the same behaviour, your email address of [email protected] is the old one. I reckon even if you change that in AD and dirsync it will not change. This is OK but we think that if someone came to school in the future needing the same (old) username it wouldn't create the account as this schoolname.onmicrosoft.com will already exist...
sonofsanta Posted November 19, 2014 Posted November 19, 2014 I use an Excel file where I can type in their old name, their new name, and it generates all the columns I need to save out to a CSV with the columns oldFName,oldLName,newFName,newLName,type,dn,oldUsername,oldUpn,oldHmdir,oldProfile,oldEmail,newUsername,newUpn,newDisplayName,newHmdir,newProfile,newEmail,newO365Email,newOrgEmail That CSV is copied to a domain controller as renameUser.csv, where the following script gets run Import-Csv .\renameUser.csv | foreach-object { # change majority of details $newUsername = $_.newUserName $newDisplayName = $_.newDisplayName Set-ADUser -Identity $_.oldUsername -SamAccountName $newUsername -UserPrincipalName $_.newUpn -EmailAddress $_.newUpn -DisplayName $_.newDisplayName -GivenName $_.newFName -Surname $_.newLName -HomeDirectory $_.newHmdir -HomeDrive "N:" -ProfilePath $_.newProfile -PassThru # Change distinguished name (can't be done through Set-ADUser) Try { Rename-ADObject -identity $_.dn -NewName $_.newDisplayName Write-Host "Renamed to $newDisplayName" -ForegroundColor Green } Catch { Write-Host "Display name not changed: $newUsername may already exist." -ForegroundColor Red } # Add old username to end of current description $newDescription = "(was " + $_.oldUsername + ")" Get-ADUser $_.newUsername -Properties Description | ForEach-Object { Set-ADUser $_ -Description "$($_.Description) $newDescription" } # Rename existing directories (makes our lives easier in future) Rename-Item $_.oldHmdir $newUsername $oldProfile = $_.oldProfile + ".V2" $newProfile = $newUsername + ".V2" Rename-Item $oldProfile $newProfile # Sort out proxy addresses, need to set up variables as doesn't seem to like $_. nomenclature $mailNickname = $newUsername $oldEmail = $_.oldEmail $lowerOldEmail = $oldEmail.ToLower() $newEmail = $_.newEmail $o365Email = $_.newO365Email $orgEmail = $_.newOrgEmail Get-ADUser $newUsername | Set-ADUser -Remove @{proxyAddresses=$oldEmail} -Replace @{mailNickname=$mailNickname} -Add @{proxyAddresses=$lowerOldEmail,$newEmail,$o365Email,$orgEmail} -PassThru Write-Host "`n============================================`n" -ForegroundColor Green } That's slightly longer than most people will need as every user here has at least three email addresses - @school.county.sch.uk, @school.org and @school.onmicrosoft.com It changes the username and all relevant fields to match (displayName etc.), renames & updates the Profile and Home directories, appends their old username to the description for clarity, maintains all their old email addresses as proxyAddresses and sets up all their new addresses. I then copy the CSV to my DirSync server (that has all the PowerShell modules installed) and run the following simple script to change their UPN (i.e. login) # based on http://community.office365.com/en-us/forums/148/t/17328.aspx Connect-MSOLService -Credential $adminCredential $Users = Import-Csv D:\Office365\renameUser.csv # change UPN for login $Users | ForEach-Object { Set-MsolUserPrincipalName -UserPrincipalName $_.oldUpn -NewUserPrincipalName $_.newUpn } At a guess, for the specific problem you're having, I'd say check the targetAddress attribute (should be SMTP:[email protected] - make sure SMTP is capitalised) and the userPrincipalName (should be [email protected].sch.uk- whatever your email address is). UPN has to be updated in Office365 directly with PowerShell - it won't rename based on your AD alone.
Boredguy Posted November 19, 2014 Posted November 19, 2014 As the OnMicrosoft.com address is not meant be updated via DirSync. One solution could be to remove the user from DirSync (for us we would just move them to another OU), then update the OnMicrosoft.com address in 365, then put the user back into DirSync. However in the last 17 years I've not had 2 members of staff with the username so I think we should be ok for a few more years.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now