Misc-small-projects/Commissions/Fredrik/Make Users.ps1
Daniel Løvbrøtte Olsen cf923bb63e Made a powershell to add users to win server
Made it for Fredrik
2015-10-21 19:31:17 +02:00

19 lines
864 B
PowerShell

############################################
## Script by Daniel Løvbrøtte Olsen, 1ELA ##
## For Fredrik Refstie ##
############################################
$Users = Import-Csv .\Users.csv
forEach ($User in $Users)
{
$first = $User.first[0..1]
$last = $User.last[0..2]
$username = "$first$last"
$username = $username -replace " ", ""
"dsadd user `"cn=$username, ou=Illuminati, dc=datavg2, dc=local -fn Joetta -ln Heckel pwd Admin123" | out-file run.bat -Encoding "UTF8" -Append
}
"echo Script has finished running, thanks based Daniel in 1ELA for making our lives easier" | out-file run.bat -Encoding "UTF8" -Append
"PAUSE" | out-file run.bat -Encoding "UTF8" -append
"@ECHO OFF" | out-file run.bat -Encoding "UTF8" -append
"DEL `"%~f0`"" | out-file run.bat -Encoding "UTF8" -append
Start-Process "cmd.exe" "/c run.bat"