# Displayname Nachname, Vorname + Initialen
Get-ADUser -Filter * -SearchBase “OU=User Accounts,OU=User,OU=ORG,DC=ndsedv,DC=de” -Properties sn, givenname, initials |
Foreach-object {
$ini = “$($_.sn)” + “”, “$($_.givenname)”
$first,$last = ($ini.toupper()).Split(” “)
$i = $first[0]+$last[0]
Set-ADUser -Identity $_ -replace @{displayname=”$($_.sn), $($_.givenname)”;initials=”$i”.Trim() } -passthru}
# Displayname Nachname, Vorname
Get-ADUser -Filter * -SearchBase “OU=User Accounts,OU=User,OU=ORG,DC=ndsedv,DC=de” -Properties sn, givenname | Foreach-object { Set-ADUser -Identity $_ -replace @{displayname=(([string]”$($_.sn), $($_.givenname)”).Trim())}}
# Displayname Vorname, Nachname
Get-ADUser -Filter * -SearchBase “OU=User Accounts,OU=User,OU=ORG,DC=ndsedv,DC=de” -Properties sn, givenname | Foreach-object { Set-ADUser -Identity $_ -replace @{displayname=(([string]”$($_.givenname), $($_.sn)”).Trim())}}