Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

activedirectory:upnkorrigieren

UserPrincipalName anpassen

Script

import-module activedirectory
 
$Credential = get-credential
$Server = "swedc1"
$DomainSuffix = "swecom.de"
$UserList = get-aduser -filter * -properties userPrincipalName -Server $Server -Credential $Credential
 
foreach ($User in $UserList)
{
	$UPN = ""
	$UPN = $User.SamAccountName + "@" + $DomainSuffix
	if ($User.UserPrincipalName -ne $UPN) 
	{
		$User.SamAccountName + ";" + $User.UserPrincipalName + ";" + $UPN >> out.csv
		Set-ADUser -identity $User.SamAccountName -UserPrincipalName $UPN -Server $Server -Credential $Credential
	}
}

activedirectory/upnkorrigieren.txt · Zuletzt geändert: 2016/04/02 00:48 (Externe Bearbeitung)