Advertisement
Guest User

Untitled

a guest
May 16th, 2018
1,400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $Users = Import-Csv -Path "C:\Users\Administrator\Desktop\Book2.csv"            
  2. foreach ($User in $Users)            
  3. {            
  4.     $Displayname = $User.'Firstname' + " " + $User.'Lastname'            
  5.     $UserFirstname = $User.'Firstname'            
  6.     $UserLastname = $User.'Lastname'            
  7.     $OU = $User.'OU'            
  8.     $SAM = $User.'SAM'            
  9.     $UPN = $User.'Firstname' + "." + $User.'Lastname' + "@" + $User.'domain.com.local'            
  10.     $Description = $User.'Description'            
  11.     $Password = $User.'Password'            
  12.     New-ADUser -Name "$Displayname" -DisplayName "$Displayname" -SamAccountName $SAM -UserPrincipalName $UPN -GivenName "$UserFirstname" -Surname "$UserLastname" -Description "$Description" -AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) -Enabled $true -Path "$OU" -ChangePasswordAtLogon $true –PasswordNeverExpires $false -server domain.com.local            
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement