daily pastebin goal
58%
SHARE
TWEET

Update UPN for AD accounts in a specific OU recursive

anonit Oct 7th, 2018 20 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. # Update UPN for AD accounts in a specific OU recursive
  2.  
  3. Import-Module ActiveDirectory
  4. $oldSuffix = "anonit.local"
  5. $newSuffix = "anonit.net"
  6. $ou = "OU=UsersOU,DC=anonit,DC=local"
  7. $server = "anonit-dc-01"
  8. Get-ADUser -SearchBase $ou -filter * | ForEach-Object {
  9.     $newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix)
  10.     $_ | Set-ADUser -server $server -UserPrincipalName $newUpn
  11. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top