I want to create a portion of the script that checks if the samAccountNameexists based on the givenName and surName that is entered at the beginning of the script. If it does, I'd like to have the script create thesamAccountName based on the first two letters of the first name then the full last name.
For example:
$GivenName = "John"
$SurName = "Test"
$SamAccountName = "$($GivenName.Substring(0,1))$Surname"
Returns: Jtest
I'd like the samAccountName to be:
Jotest if the samAccountName of Jtest exists already.