Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Verify against Active Directory to see if SAM already exists.

$
0
0

First off I'd like to "tip my hat" to the admins on this forum. Some of the best formulated /clear answers compared to other sites.

I'll get right to the point, I'm a little loss in my code write now. Here's the context:

Importing a CSV.  Looking for FirstName and LastName (in those order). Want the first letter of the FirstName. If a hyphen (-) is in the fist name, take first letter behind the hyphen position and add it to the first letter. That works fine, did the same thing with spaces, and applied the same basic principal to the LastName variable. See example below: 

FirstName     LastName     SAM

Jean-Paul     Smith            jpsmith

Jean Luc       Gold             jgold

Mike             Lee-Quan     ml-quan

What I would like to be able to verify against the DC and see if any SAM already exist:

example: Jean-Pierre Smith exist so Jean-Paul Smith cannot use jpsmith. The the new user would need to get the second letter of the first name. So for Jean-Paul Smith it would be jepsmith. If it is some trouble as a code I would settle with adding a "2" at the end of the SAM : jpsmith2

Thanks in advance.

A very tired admin.

 

 


Viewing all articles
Browse latest Browse all 8583

Trending Articles