Advertisement
Guest User

asdf

a guest
Jul 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Import-Module ActiveDirectory
  2.  
  3. $Csvpath = "C:\we.csv"
  4.  
  5. $AccountExpires = (Get-Date).AddDays(+365)
  6.  
  7. $Users = Import-CSV -Path $Csvpath -Delimiter ";"
  8.  
  9.  
  10. $CurrDomain = Get-ADForest | Select-Object -ExpandProperty name
  11.  
  12.  
  13. ForEach($User in $Users){
  14.  
  15.  
  16. $UserParams =@{
  17. GivenName = $User.FN
  18. SurName = $User.LN
  19. Displayname = $User.FN + " " + $User.LN
  20. Name = $User.FN + " " + $User.LN
  21. SamAccountName = $User.UN
  22. UserPrincipalName = $User.FN + "." + $User.LN + "@" + $CurrDomain
  23. Description = $User.Desc
  24. AccountPassword = $User.PW | ConvertTo-SecureString -AsPlainText -Force
  25. $Mail = $User.Mail
  26. Enabled = $True
  27.  
  28.  
  29. }
  30. New-ADUser @UserParams
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement