-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmailAndUser.ps1
38 lines (28 loc) · 977 Bytes
/
EmailAndUser.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#Variables
$Names = @()
$Name = @()
$NameNoSpecialFirst = @()
$NameNoSpecialLast = @()
$NamesNoSpecial = @()
$NameNoSpecial = @()
$EmailAddress1 = @()
$EmailAddress2 = @()
$Username1
$Username2
$Domain = "Domain Name"
$NameCSV = "names.csv"
#Import CSV Of Names
$Names = Import-Csv $NameCSV
#Create List of First Names and Last Names
ForEach ($Name in $Names) {
$NameNoSpecialFirst = $Name.First -replace '[^\p{L}\p{Nd}]'
$NameNoSpecialLast = $Name.Last -replace '[^\p{L}\p{Nd}]'
$NamesNoSpecial += [PSCustomObject]@{First=$NameNoSpecialFirst;Last=$NameNoSpecialLast}
}
#Build User Names
ForEach ($NameNoSpecial in $NamesNoSpecial) {
$EmailAddress1 += $NameNoSpecial.Last + $NameNoSpecial.First.Substring(0,1) + "@" + $Domain
$Username1 += $NameNoSpecial.Last + $NameNoSpecial.First.Substring(0,1)
$EmailAddress2 += $NameNoSpecial.First.Substring(0,1) + $NameNoSpecial.Last + "@" + $Domain
$Username2 += $NameNoSpecial.First.Substring(0,1) + $NameNoSpecial.Last
}