Advertisement
Guest User

Untitled

a guest
May 26th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. $objOU=[ADSI]”LDAP://OU=Student,OU=Wsiz,DC=site1,DC=w2k16,DC=pl”
  2. $dataSource=import-csv “C:\Scripts\import.csv”
  3. foreach($dataRecord in $datasource) {
  4. $cn=$dataRecord.FirstName + ” ” + $dataRecord.LastName
  5. $sAMAccountName=$dataRecord.FirstName + “.” + $dataRecord.LastName
  6. $givenName=$dataRecord.FirstName
  7. $sn=$dataRecord.LastName
  8. $sAMAccountName=$sAMAccountName.ToLower()
  9. $displayName=$sn + “, ” + $givenName
  10. $userPrincipalName=$sAMAccountName + “@site1.w2k16.pl”
  11. $objUser=$objOU.Create(“user”,”CN=”+$cn)
  12. $objUser.Put(“sAMAccountName”,$sAMAccountName)
  13. $objUser.Put(“userPrincipalName”,$userPrincipalName)
  14. $objUser.Put(“displayName”,$displayName)
  15. $objUser.Put(“givenName”,$givenName)
  16. $objUser.Put(“sn”,$sn)
  17. $objUser.Put("userLogonName",$userLogonName)
  18. $objUser.SetInfo()
  19. $objUser.SetPassword(“Passw0rd”)
  20. $objUser.psbase.InvokeSet(“AccountDisabled”,$false)
  21. $objUser.SetInfo()
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement