In: Computer Science
In PowerShell ISE create a script.
Use the text file “its3410Users.txt” (found on Canvas) and import the users into your domain controller. The user file has a first name, last name, and department. Using this information, create users with the following specifications:
I have used powershell 2.0.
$datas = Get-Content –Path C:\
its3410Users.txt
$passwrd = “Ch@nge123Me!”
foreach ($data in $datas){
$firstname = $data.firstname
$lastname = $data.lastname
$username = $firstname + “.” +$lastname
$user_principal_name =$username + “
@its3410.net”
$partial_data = $username + “,” + $user_principal_name
}
if(
$department
–eq
'OU'
){
$user = $partial_data + “,OU”
}
if(
$department
-eq
NULL
){
$user = $partial_data + “,NA”
}
}
if(
$login_attempt){
Write-Verbose
"Change Password"
}
$datas = Get-Content –Path C:\
its3410Users.txt
$passwrd = “Ch@nge123Me!”
foreach ($data in $datas){
$firstname = $data.firstname
$lastname = $data.lastname
$username = $firstname + “.” +$lastname
$user_principal_name =$username + “
@its3410.net”
$partial_data = $username + “,” + $user_principal_name
}
if(
$department
–eq
'OU'
){
$user = $partial_data + “,OU”
}
if(
$department
-eq
NULL
){
$user = $partial_data + “,NA”
}
}
if(
$login_attempt){
Write-Verbose
"Change Password"
}