PAW icon indicating copy to clipboard operation
PAW copied to clipboard

shadowGroups.ps1 // problem with comma in username

Open StefanSa opened this issue 4 years ago • 3 comments

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.

StefanSa avatar Jan 15 '21 11:01 StefanSa

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??

utsecnet avatar Jan 15 '21 18:01 utsecnet

Rich, yes just right

StefanSa avatar Jan 15 '21 19:01 StefanSa

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]
        }

StefanSa avatar Aug 13 '21 13:08 StefanSa