Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Update UPN for AD accounts in a specific OU recursive
- Import-Module ActiveDirectory
- $oldSuffix = "anonit.local"
- $newSuffix = "anonit.net"
- $ou = "OU=UsersOU,DC=anonit,DC=local"
- $server = "anonit-dc-01"
- Get-ADUser -SearchBase $ou -filter * | ForEach-Object {
- $newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix)
- $_ | Set-ADUser -server $server -UserPrincipalName $newUpn
- }
Add Comment
Please, Sign In to add comment