Created
May 29, 2014 14:42
-
-
Save davegreen/ca0e8af2378f4e5f87d7 to your computer and use it in GitHub Desktop.
Quick one-liner for setting UPNs for users to match their email address (useful for working with Azure, O365, etc.)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Set UPN for all users with mobile phone numbers to email address | |
Get-ADuser -Filter * -Properties mobilephone, mail | where {$_.mobilephone -and $_.mail -ne $_.userPrincipalName} | ForEach-Object {Set-ADuser -Identity $_.ObjectGUID -UserPrincipalName $_.mail} | |
#Set UPN for all users to email address | |
Get-ADuser -Filter * -Properties mail | where {$_.mail -ne $_.userPrincipalName} | ForEach-Object {Set-ADuser -Identity $_.ObjectGUID -UserPrincipalName $_.mail} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment