M.Byford-Rew Posted April 19, 2017 Posted April 19, 2017 I'm trying to migrate an O365 Domain to a new Tenant. It's going okay but before I can remove the domain from the old tenant I need to completely remove any references to the 'migrating' domain suffix. I've removed them all from most accounts using PowerShell and I was happy that things were going well. However I've hit a snag that's got me stumped for a couple of days. There are Proxy Email Addresses on some of my users. I can see which ones these are but I can't see any commands to remove them using PowerShell. They're identified sing this: Get-MsolUser -UserPrincipalName "username of user here" | select -ExpandProperty ProxyAddresses This list reveals the email account that I need to remove however there is no Set-MSOLUser command to remove Proxy Email addresses. I've looked in Exchange Online EAC to see if the account has an Exchange Mailbox which they do not. They do appear as a contact but the email address I want to remove is not visible in the properties. When checking within the O365 | Admin Center | Users | Active users the user's properties again do not show the email address that I want to remove. Is there a PowerShell Command that will remove entries from the ProxyAddresses collection which is returned by the Get-MSOLUser command? Regards, Martin
M.Byford-Rew Posted April 20, 2017 Author Posted April 20, 2017 https://support.arete9.co.uk/hc/en-gb/articles/204765851-Managing-Active-Directory-ProxyAddresses-in-PowerShell?mobile_site=true
M.Byford-Rew Posted April 21, 2017 Author Posted April 21, 2017 [h=2]Unable to Remove or Delete ProxyAddresses / EmailAddresses from MSOLADUserobjects prior to Deleting a domain from O365[/h] [h=3]Problem symptom:[/h]You are unable to delete a domain from O365 as there areemail addresses recorded for the MSOLUser within the ProxyAddresses field. Problem users can be identified using the following PSextract: Example domain name = abc.com $UsersInError = Get-MsolUser -All | ?{$_.ProxyAddresses -like"*abc.com*"} | Sort-Object Displayname These users correspond with Exchange Online | MailUserobjects. Iterate through each of the MSOLUser objects and foreach one, selectand remove each associated EmailAddress. Once removed, immediately add the sameaddress again. This action appears to realign the values seen from MSOLUser–ProxyAddresses and MailUser EmailAddresses. As each is processed they disappear from the problem usersidentified. This can be verified by running the check above again or by tryingto Delete the domain through the O365 Admin console. $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationNameMicrosoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/-Credential $UserCredential-Authentication Basic-AllowRedirection Import-PSSession $Session Connect-MsolService $UsersInError = Get-MsolUser -All | ?{$_.ProxyAddresses -like"*abc.com*"} | Sort-Object Displayname #How many users are problem users $UsersInError.Count Write-Host #Which users are in error $UsersInError Write-Host foreach($UserInErrorin $UsersInError) { $User = Get-MailUser -Identity $UserInError.UserPrincipalName Set-Mailbox-Identity $User -EmailAddresses= $User.EmailAddresses foreach($address in$User.EmailAddresses) { Write-Host$address Set-MailUser-Identity $User.DisplayName -EmailAddresses@{Remove=$address} Set-MailUser-Identity $User.DisplayName -EmailAddresses@{Add=$address} } foreach($address in$User.EmailAddresses){$address} }
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