Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. $path = Split-Path -parent $MyInvocation.MyCommand.Definition
  2. $importPath = $path + "users.txt"
  3. # EDIT to match your net bios domain name.
  4. $netBiosDomain = "corp"
  5. # EDIT adjust to your schedule needs
  6. $schedule = "weekly at Sun 12:00"
  7. # EDIT you need to adjust the password to match the password in createusers.ps1.
  8. $initialPass = ConvertTo-SecureString -AsPlainText "Passw0rd!" -force
  9. Import-CSV $importPath | ForEach-Object {
  10. $sam = $_.Username.ToLower()
  11. $username = $netBiosDomain + $sam
  12. $cred = New-Object System.Management.Automation.PSCredential ($username, $initialPass)
  13. New-SPManagedAccount -Credential $cred
  14. Set-SPManagedAccount -Identity $cred.UserName -AutoGeneratePassword -Schedule $schedule -confirm:$false
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement