Advertisement
crexin

Set-UPNBasedOnSamAccountName.ps1

Mar 3rd, 2016
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Change UPN to SamAccountName@specifieddomain
  2. # useful if needing to switch UPNs or to set UPNs before using DirSync for OnPrem to O365 Directory Synchronization
  3. # Should add domain, i.e. contoso.com to UPN Suffixes in properties in Active Directory Domains and Trusts first
  4.  
  5. Import-Module ActiveDirectory;get-aduser -filter {Name -like "*"}|foreach{Set-ADUser $_ -UserPrincipalName ("{0}@{1}" -f $_.SamAccountName,"contoso.com")}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement