Username creation

Just give input as first name and last name in inputfile

 

Jeevan bobba

Abcdef ghijklmnopqrst

It will create username and by adding v- at the beginning of username and – in between lastname-firstname

 

CLS
$Users= gc C:\Temp\abcd.txt
$Users | %{
$a = $PSItem
if (($a.Substring(0,2) -like “v-“) -and ($a -notmatch ” “) ){“$a”}
else{
$SamAccountName = ((($a -split ” “)[-1..-5] -join “-“).Insert(0,’z-‘))
#$SamAccountName
#If ($samaccountname.length -ge 19){$samaccountname.remove(19)} else {$SamAccountName}
if ($SamAccountName.length -ge 19){$SamAccountName.substring(0, 19)} else {$SamAccountName}
}
}

9 Comments

  1. I like the valuable information you provide in your articles. I will bookmark your blog and check again here regularly. I’m quite certain I will learn plenty of new stuff right here! Best of luck for the next!

  2. What i do not realize is in reality how you’re no longer really a lot more smartly-preferred than you might be now. You’re very intelligent. You already know thus considerably in relation to this topic, made me in my view consider it from numerous numerous angles. Its like men and women don’t seem to be involved until it’s something to do with Lady gaga! Your own stuffs excellent. All the time handle it up!

Leave a Reply

Your email address will not be published.