Snel SharePoint 2013 service accounts maken

Tijdens de installatie van een SharePoint 2013 infrastructuur vraag ik de ICT afdeling om circa 10 service accounts aan te maken in het Active Directory. 9 van de 10 keer moet ik ze zelf in het Active Directory inkloppen. Dit kan natuurlijk veel sneller met Powershell !

XML antwoordbestand:

<users>

<user FirstName="SPS 2013" LastName="Admin (Setup)" SamAccountName="sps2013admin" Password="P@ssw0rd" />
 <user FirstName="SPS 2013" LastName="SQL Service" SamAccountName="sps2013sql" Password="P@ssw0rd" />
 <user FirstName="SPS 2013" LastName="Farm" SamAccountName="sps2013farm" Password="P@ssw0rd" />
 <user FirstName="SPS 2013" LastName="Application Pool" SamAccountName="sps2013apppool" Password="P@ssw0rd" />
 <user FirstName="SPS 2013" LastName="Service Apps" SamAccountName="sps2013serviceapps" Password="P@ssw0rd" />
 <user FirstName="SPS 2013" LastName="Search Service" SamAccountName="sps2013search" Password="P@ssw0rd" />
 <user FirstName="SPS 2013" LastName="Content Crawl" SamAccountName="sps2013content" Password="P@ssw0rd" />
 <user FirstName="SPS 2013" LastName="User Profiles Sync" SamAccountName="sps2013profilesync" Password="P@ssw0rd" />
 <user FirstName="SPS 2013" LastName="Cache Super User" SamAccountName="sps2013superuser" Password="P@ssw0rd" />
 <user FirstName="SPS 2013" LastName="Cache Super Reader" SamAccountName="sps2013superreader" Password="P@ssw0rd" />

</users>

 

Daarna is het zaak om de accounts via een Powershell script in te laden:

Powershell script:

Import-Module ActiveDirectory

#AD OU where service account will be created
$OUPath = "OU=ServiceAccounts,DC=sp13,DC=local"
$passwordNeverExpires = $true
$changePasswordAtLogon = $false
#sufix for creating full user principle name
$userPrincipleSufix = "@sp13.local"

 [xml]$userfile = Get-Content "C:\Temp\SP2013_ServiceAccounts.xml"
 $nodes = $userfile.SelectNodes("//user")

 foreach ($node in $nodes) {
 $username = $node.SamAccountName
 $displayName = $node.FirstName + " " + $node.LastName
 $password = ConvertTo-SecureString $node.Password -AsPlainText -force
 $userPrincipleName = $username + $userPrincipleSufix

 Write-Host "Creating user with SamAccountName $username"

 $user = New-ADUser -Name $displayName -SamAccountName $username -UserPrincipalName $userPrincipleName -GivenName $node.FirstName -Surname $node.LastName -DisplayName $displayName -Path $OUPath -AccountPassword $password -PasswordNeverExpires $passwordNeverExpires -ChangePasswordAtLogon $changePasswordAtLogon -Enabled $true

Write-Host "User wit SamAccountName $username successfully created"
read-host "continue…" }

Leave a Reply

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Deze website gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.