Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.