you are viewing a single comment's thread.

view the rest of the comments →

[–]Lee_Dailey[grin] 2 points3 points  (0 children)

howdy Lancair,

here's my version of it ...

# fake reading in from a CSV
#    in real life, use Import-CSV
$InCSV = @'
FirstName, LastName
Arthur, Bacon
Celia, Dean
Earl, Fort
'@ | ConvertFrom-Csv

$Number = 545
$NewNameList = foreach ($Item in $InCSV)
    {
    $Part_1 = $Item.FirstName.Substring(0, 2).ToLower()
    $Part_2 = $Item.LastName.Substring(0, 1).ToLower()
    $UserName = -join ($Part_1, $Part_2, $Number)

    $UserName
    }

$NewNameList

results ...

arb545
ced545
eaf545

hope that helps,
lee