Hi @Alex Brown ,
maybe this is helpful to start:
Content of CSV file:
ID,FirstName,LastName
1,Peter,Smith
2,James,Bond
3,Mickey,Roth
Script:
$NewLines = "newID,DisplayName,Email,oldID,FirstName,LastName`r`n" #Define new header
Import-Csv -Path junk.csv | # read csv file
ForEach-Object { # for each line in csv
$i = $_.ID # get ID value
$f = $_.FirstName # get FirstName value
$l = $_.LastName # get LastName value
$newID = $i + $f.Substring(0,1) + $l.Substring(0,1) # build new ID - ID + first char of firstname and lastname
$displayName = '"' + "$l, $f" + '"' # build DisplayName with quotes - , and space in display name
$emailAddress = "$f.$l" + "@test.org" # build email-address
$NewLines += "$newID,$displayName,$emailAddress,$i,$f,$l" + "`n" # build new lines with new values
}
$NewLines
Content of $NewLines:
newID,DisplayName,Email,oldID,FirstName,LastName
1PS,"Smith, Peter",******@test.org,1,Peter,Smith
2JB,"Bond, James",******@test.org,2,James,Bond
3MR,"Roth, Mickey",******@test.org,3,Mickey,Roth
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten