Change upn-suffix for all the users in certain OU

Get-ADUser -Filter
{UserPrincipalName -like
“*@domain.local”} -SearchBase “OU=whateverisright,DC=contoso,DC=com”
|
ForEach-Object {
   
$UPN =
$_.UserPrincipalName.Replace(“domain.local”,”newdomain.local”)
   
Set-ADUser
$_ -UserPrincipalName
$UPN
}
Easy as opening a banana, right? https://www.youtube.com/watch?v=nBJV56WUDng 🙂
Author: Harri Jaakkonen

Leave a Reply

Your email address will not be published. Required fields are marked *