Created
September 30, 2016 22:04
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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