Powershell İle UserPrincipalName Değiştirme

Merhaba, aşağıdaki powershell kodu ile UserPrincipalName’i eposta adresi ile değiştirebilirsiniz.

Örnek

Kullanıcı adı “mehmetsaityilmaz@lab.local” olsun eposta adresi ise “mehmetsaityilmaz@cozumpark.com“. Aşağıdaki kod ile kullanıcı adını “mehmetsaityilmaz@cozumpark.com” olarak değiştirmiş olacaksınız.

$liste=get-aduser -Identity kullanıcı adını yazınız -Properties EmailAddress

$rep=@();$liste | %{IF($_.EmailAddress -ne $_.userprincipalname) {Write-Host $_.name;$rep+=$_}}

 $rep | %{IF($_.EmailAddress -ne $_.userprincipalname) {Write-Host $_.name;Set-ADUser -Identity $_.distinguishedName -UserPrincipalName $_.EmailAddress}}

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir