Skip to content

Instantly share code, notes, and snippets.

@sob
Last active June 28, 2017 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sob/f121445435ad2ef9a8efd0cae57d55e0 to your computer and use it in GitHub Desktop.
Save sob/f121445435ad2ef9a8efd0cae57d55e0 to your computer and use it in GitHub Desktop.
Remove vanity domain from O365
Get-MsolUser | ForEach-Object { $upn = $_.UserPrincipalName.Split("@")[0] + "@holytrinityschools.onmicrosoft.com"; Set-MsolUserPrincipalName -ObjectId $_.ObjectId -NewUserPrincipalName ($upn) }
Get-DistributionGroup | ForEach-Object { $email = $_.PrimarySmtpAddress.split("@")[0] + "@holytrinityschools.onmicrosoft.com"; Set-DistributionGroup $_.identity -EmailAddresses $email }
Get-UnifiedGroup | ForEach-Object { $email = $_.PrimarySmtpAddress.split("@")[0] + "@holytrinityschools.onmicrosoft.com"; Set-UnifiedGroup $_.identity -EmailAddresses $email }
Get-User | Where-Object { $_.RecipientType -eq "MailUser"} | Remove-MailUser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment