Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

New-ADUser Script Help

$
0
0

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. 


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>