PAW
PAW copied to clipboard
shadowGroups.ps1 // problem with comma in username
hi rich, thanks again for this very helpful PAW concept, i hope you are doing well in the difficult times at the moment. There is a requirement to change the username (cn) from "first name surname" to "surname, first name". Unfortunately the script has a problem with the comma in between. Can you help adapt the script so that it works correctly both with and without a comma?
Thanks for your help and time.
So would that mean your DN would look something like this: CN=Johnson, Rich,OU=Tier0,OU=PAWAdmins,OU=Users,OU=Merrick,DC=devsec,DC=local
Is that even possible??
Rich, yes just right
Hi Rich, i hope you are doing well. i have to correct myself, it is possible to differentiate between users with no commas in their name, herewith:
if($user.name -match ','){
# a comma was found in the Name attribute value
$dn = $user.distinguishedname
$department = ($dn -split '[,\=]')[4]
$locale = ($dn -split '[,\=]')[6]
}
else {
# no comma was found in the Name attribute value
$dn = $user.distinguishedname
$department = ($dn -split '[,\=]')[3]
$locale = ($dn -split '[,\=]')[5]
}