Monday, October 25, 2021

How to copy all UPNs (usernames) to email address field in AD.

Check users email fields-
 get-aduser -Filter * -Properties mail | select name,mail | Out-GridView


Command to copy-
Get-ADUser -LDAPFilter '(userPrincipalName=*)' ` -Properties userPrincipalName,mail | Select-Object * | ` ForEach-Object { Set-ADObject -Identity ` $_.DistinguishedName -Replace ` @{mail=$($_.userPrincipalName)} }

No comments:

Post a Comment