SHARE
TWEET

Untitled

a guest Sep 22nd, 2016 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $Users = Import-Csv -Delimiter "," -Path ".\NewUsersDom4.csv"
  2. foreach ($User in $Users)
  3. {
  4. $NEWADUSER = @{
  5.     Name = $User.FirstName + " " + $User.LastName;
  6.     DisplayName = $User.FirstName + " " + $User.LastName;
  7.     SamAccountName = $User.samAccountName;
  8.     UserPrincipalName = $User.samAccountName + "@" + $User.Domain;
  9.     GivenName = $User.FirstName;
  10.     Surname = $User.LastName;
  11.     AccountPassword = (ConvertTo-SecureString $User.Password -AsPlainText -Force);
  12.     Enabled = $true;
  13.     Path = $User.ParentOU;
  14.     ChangePasswordAtLogon = $false;
  15.     PasswordNeverExpires = $true;
  16.     HomeDrive = "H";
  17.     HomeDirectory = $User.ShareName + "\" + $SAM;
  18.     }
  19.  
  20. $NEWGROUPMEMBER = @{
  21.     Identity = $User.Group;
  22.     Members = $User.samAccountName;
  23.     }
  24.  
  25. #New-ADUser Command
  26. New-ADUser @NEWADUSER;
  27.  
  28. #Add User to Group
  29. Add-ADGroupMember @NEWGROUPMEMBER;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top