Skip to content

Instantly share code, notes, and snippets.

@rwindegger
Created September 30, 2016 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwindegger/808dee4c3bc234a1a7c75b2d27c58a37 to your computer and use it in GitHub Desktop.
Save rwindegger/808dee4c3bc234a1a7c75b2d27c58a37 to your computer and use it in GitHub Desktop.
This script sets up sharepoint managed accounts based on the users.txt input file.
$path = Split-Path -parent $MyInvocation.MyCommand.Definition
$importPath = $path + "users.txt"
# EDIT to match your net bios domain name.
$netBiosDomain = "corp"
# EDIT adjust to your schedule needs
$schedule = "weekly at Sun 12:00"
# EDIT you need to adjust the password to match the password in createusers.ps1.
$initialPass = ConvertTo-SecureString -AsPlainText "Passw0rd!" -force
Import-CSV $importPath | ForEach-Object {
$sam = $_.Username.ToLower()
$username = $netBiosDomain + $sam
$cred = New-Object System.Management.Automation.PSCredential ($username, $initialPass)
New-SPManagedAccount -Credential $cred
Set-SPManagedAccount -Identity $cred.UserName -AutoGeneratePassword -Schedule $schedule -confirm:$false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment