Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $Domain = "regen.lan"
  2. $OUs = @("Leerlingen", "Docenten", "Directie", "Administratie", "")
  3. foreach ($OU in $OUs){
  4.     New-ADOrganizationalUnit $OU
  5. }
  6.  
  7.  
  8. $Users = Import-Csv -Delimiter "," -Path "database.csv"            
  9. foreach ($User in $Users)            
  10. {            
  11.     $VolledigeNaam = $User.vnaam + " " + $User.tv + " " + $User.anaam
  12.     $Voornaam = $User.vnaam
  13.     $Achternaam = $User.anaam            
  14.     $OU = "CN=$User.ou, DC=regen, DC=lan"
  15.     $Gebruikersnaam = $User.nummer          
  16.     $Group = $User.soort
  17.     # $UPN = $User.Firstname + "." + $User.Lastname + "@" + $User.Maildomain                      
  18.     $Wachtwoord = $User.wachtwoord
  19.     $newGroup=New-ADGroup -Path $OU -Name $Group -GroupScope DomainLocal -GroupCategory Distribution  
  20.     New-ADUser -Name "$VolledigeNaam" -DisplayName "$VolledigeNaam" -SamAccountName $Gebruikersnaam -UserPrincipalName $Gebruikersnaam -GivenName "$Voornaam" -Surname "$Achternaam" -AccountPassword (ConvertTo-SecureString $Wachtwoord -AsPlainText -Force) -Enabled $true -Path "$OU" -ChangePasswordAtLogon $false –PasswordNeverExpires $true -server $Domain            
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement