Skip to content

Instantly share code, notes, and snippets.

@mikeplate
Created September 26, 2012 19:15
Show Gist options
  • Save mikeplate/3789958 to your computer and use it in GitHub Desktop.
Save mikeplate/3789958 to your computer and use it in GitHub Desktop.
Create all users required by the AutoSPInstaller script
$user_list = "SPS_INSTALL", "SQL_SERVICE", "SPS_FARM", "SPS_APP_POOL1", "SPS_MYSITE", "SPS_SERVICES", "SPS_SEARCH", "SPS_CRAWL", "SPS_PROFILE", "SPS_CACHEADM", "SPS_CACHERD"
function Gen-Password([int]$length) {
$assembly = Add-Type -AssemblyName System.Web
[System.Web.Security.Membership]::GeneratePassword($length, 2)
}
function Get-ScriptDirectory() {
$invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $invocation.MyCommand.Path
}
$output_file = Get-ScriptDirectory
$output_file += "\sp-create-users-output.txt"
$server = [ADSI]"WinNT://localhost"
foreach ($user_data in $user_list) {
$pwd = Gen-Password 10
# $user = $server.Create("User", $user_data[0])
# $user.SetPassword($user_data[1])
# $user.SetInfo()
($user_data + " " + $pwd) >> $output_file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment