New-mailUser / Username issues

by Aug 20, 2014

Hey Everyone,

Brand new here in the PowerShell.com community (and to be honest, still pretty new to powershell as a whole) … and I was hoping that someone could point me in the right direction.

I'm doing a large bulk new-MailUser add to my system here at work — pretty novice level stuff… just importing names and email and titles and such from a csv.  However, the roadblock I hit is on the username creation.  Normally our naming convention is 1st letter of first name + last name ie:  John Smith = J Smith.  As you would imagine, this could get problematic when you're importing 400+ users. 

My question is this…

How would I go about creating a logic to add a number at the end of a username that already exists.  Ie  — JSmith already exists, then create JSmith1

Like I said, this maybe a super novice question, but any direction would be very appreciated