Requirements:
– Powershell 2.0
– CSV file
Attributes Used:
- FirstName
- LastName
- City
- Department
- Job Title
- Logon Name
- Password
- Description
- Script (Logon Script)
- H drive (Logon file share letter)
- domain name
PS1 script:
Function Provision {
PROCESS {
Write-Host $_.samAccountName
}
}
Function ProvisionInputCSV {
Param ([string]$filename)
$users = Import-CSV C:powershellusers.csv
foreach ($user in $users) {
$ht = @{‘givenName’=$user.”First Name”;
‘sn’= $user.”Last Name”;
‘title’= $user.”Job Title”;
‘department’= $user.Department;
‘displayName’= $user.”First Name” + ” ” + $user.”Last Name”;
‘city’= $user.”City”;
‘password’= $user.Password;
‘samAccountName’= $user.”Logon Name”;
‘description’= $user.”Description”;
‘mail’= $user.”E-Mail”;
‘scriptPath’= $user.script;
‘homeDrive’= $user.”H drive”;
‘userPrincipalName’= $user.”domain name”
}
Write-Output $ht
}
}
ProvisionInputCSV c:powershellusers.csv | Provision
This script is using the following