forked from asksven/sharepoint2013-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_03_CreateADAccounts.ps1
33 lines (27 loc) · 1.47 KB
/
03_03_CreateADAccounts.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# by Sven Knispel under ter terms of the Ms-PL license (see license.txt)
#
# Creates the accounts needed by AutoSPInstaller
#
# History
# 1.0 2014-01-03 Initial version
# 1.1 2014-02-14 Externalized config
# 1.2 2014-02-16 Make sure to add user with a never expiring password
########################################################################
Get-Content "config.txt" | foreach-object -begin {$h=@{}} -process { $k = [regex]::split($_,'='); if(($k[0].CompareTo("") -ne 0) -and ($k[0].StartsWith("[") -ne $True)) { $h.Add($k[0], $k[1]) } }
# create all the required accounts (see http://blog.lekman.com/2012/10/autospinstaller-prepare-server-hardware.html)
$Users = @("SP_Services", "SP_PortalAppPool", "SP_ProfilesAppPool", "SP_SearchService", "SP_CacheSuperUser", "SP_CacheSuperReader", "SP_Farm", "SP_SearchContent", "SP_ProfileSync", "SP_ExcelUser", "SP_VisioUser", "SP_PerfPointUser", "SP_ProjectServer", "SQL_AnalysisServices")
$password = $h.$password
Import-Module ActiveDirectory
Write-Host "(VM) $(Get-Date): Deleting and re-creating users"
foreach ($User in $Users)
{
Write-Host "(VM) $(Get-Date): $User"
}
pause
foreach ($User in $Users)
{
$SAM = $User
Write-Host "(VM) $(Get-Date): Creating user $SAM"
Remove-ADUser -Identity $SAM
New-ADUser -Name $SAM -SamAccountName $SAM -UserPrincipalName $SAM -AccountPassword (ConvertTo-SecureString $password -AsPlainText -Force) -Enabled $true -PasswordNeverExpires $true
}