Setup a SharePoint Development Environment Part 4

This is the 4th series of my post on how to set up a SharePoint Hyper-V virtual farm. In the previous posts we prepared our different servers, installed SQL and SharePoint 2013. In this post we will configure SharePoint 2013 with PowerShell. Like i already said in the previous post there will be some benefits of doing it this way. If you use the standard configuration setup wizard then SharePoint will create the databases and services for you. This also means that you don’t have control over their names, passwords or the accounts they run under.

Open the SharePoint 2013 Management Shell.

Now run the following commands. (All the commands below are using the users, passwords and names that i choose. If you want you can change them to whatever you like)

$cred\_farm = New-Object System.Management.Automation.PsCredential "S\_SPfarm",(ConvertTo-SecureString "<password>” -AsPlainText -Force)
$SecPhrase = ConvertTo-SecureString "<securePassPhrase>" -AsPlainText –Force
New-SPConfigurationDatabase –DatabaseName "SP2013\_Config" –DatabaseServer "SHP\_SQL" –AdministrationContentDatabaseName "SP2013\_Content\_AdminSite" –Passphrase $SecPhrase –FarmCredentials $Cred\_Farm
Install-SPHelpCollection –All
Install-SPFeature –AllExistingFeatures -Force
New-SPCentralAdministration -Port "9000" -WindowsAuthProvider "NTLM"

After running these commands the basic SharePoint configuration is done and the Central Administration site is provisioned on port 9000.

Now its time to register the managed accounts These accounts will be used during the further configuration. Enter the following PowerShell command to get a popup where you can enter the different credentials of the accounts. Repeat this command for every account. Use the setup accounts we created in the second post.

You can check the managed accounts you entered in Central Administration (Security – Configure managed accounts). When executing these commands have some patience. They take some time even after the commands are executed. :-)

Now lets create the different application pools. Keep the PowerShell command line window open and execute the following commands.

$ManagedAccount = Get-SPManagedAccount -Identity "rd\\S\_SPservice"
New-SPServiceApplicationPool "SPS2013\_Common" -account $ManagedAccount
$ManagedAccount = Get-SPManagedAccount -Identity "rd\\S\_SPsearch"
New-SPServiceApplicationPool "SPS2013\_Search" -account $ManagedAccount
$ManagedAccount = Get-SPManagedAccount -Identity "rd\\S\_SPadsync"
New-SPServiceApplicationPool "SPS2013\_UPS" -account $ManagedAccount

Outgoing E-mail

If you created an SMTP server feature like in the first post you can do this step. Otherwise you can skip this.

Go in Central Administration to System settings => Configure outgoing mail settings. Here you can fill in the SMTP server details.

Service Applications 

Now it’s time to create the service applications. You can create them thru Central Administration => Manage service applications. Give them a correct name and database. For the application pool use the SPS2013_Common that we created. The ones you need are the Managed Metadata, Secure Store, and Business Connectivity.

Except the State Service application. This must be activated with the following PowerShell commands.

$ServiceApp = New-SPStateServiceApplication -Name "State Service Service Application"
New-SPStateServiceDatabase -DatabaseServer "SHP\_SQL" -Name "SP2013\_StateService" -ServiceApplication $ServiceApp
New-SPStateServiceApplicationProxy -Name "State Service Application Proxy" -ServiceApplication $ServiceApp -DefaultProxyGroup
Enable-SPSessionStateService -DatabaseServer "SHP\_SQL" -DatabaseName "SP2013\_SessionStateService"

After you’ve created these 4 service applications start the first 3 thru Central Administration => Application Management => Manage services on server.

Create Web applications

Now we can start creating our web applications. Create one for a SharePoint site that well use for developing of giving demo’s and of course one for all the mysites.

Don’t forget to set the browser file handling to Permissive after you’ve created the web application. Repeat this also for the MySites.

Now create in both web applications a site collection. For the MySites use the MySite Host Template.


The Search Service application will be created using PowerShell (what else :-) ). You can use this script but don’t forget to adjust it to your environment names.

Add-PSSnapin Microsoft.SharePoint.PowerShell 

## Change these per your environment ##
$databaseServerName = "shp\_sql"
$searchServerName = "SP2013"
$saAppPoolName = "SP2013\_Search"
$appPoolUserName = "rd\\SHP\_Search"
$IndexLocation = "D:\\SP2013Search"
## Service Application Names ##
## Included Usage and Health, as it does get provisioned and if you want to define DB name ##
## Also Usage Proxy Status is stopped which cause Search Application Topology to not find Admin Service ##
$searchSAName = "SharePoint Server Search"
$usageSAName = "Usage and Health Data Collection Service"

$saAppPool = Get-SPServiceApplicationPool -Identity $saAppPoolName 
if($saAppPool -eq $null)
  Write-Host "Creating Service Application Pool..."

  $appPoolAccount = Get-SPManagedAccount -Identity $appPoolUserName 
  if($appPoolAccount -eq $null)
      Write-Host "Please supply the password for the Service Account..."
      $appPoolCred = Get-Credential $appPoolUserName
      $appPoolAccount = New-SPManagedAccount -Credential $appPoolCred 

  $appPoolAccount = Get-SPManagedAccount -Identity $appPoolUserName 

  if($appPoolAccount -eq $null)
    Write-Host "Cannot create or find the managed account $appPoolUserName, please ensure the account exists."
    Exit -1

  New-SPServiceApplicationPool -Name $saAppPoolName -Account $appPoolAccount  > $null

Write-Host "Creating Usage Service and Proxy..."

$serviceInstance = Get-SPUsageService

New-SPUsageApplication -Name $usageSAName -DatabaseServer $databaseServerName -DatabaseName "SP2013\_UsageDB" -UsageService $serviceInstance > $null

$usa = Get-SPServiceApplicationProxy | where {$\_.TypeName -like "Usage\*"} 

To ensure that SharePoint can crawl itself we must disable the loopBackCheck. More info on this can be found here. In a nutshell all you have to do is startup the registry editor by running “regedit”. Locate the following key: **“HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa”
**add a DWORD value “DisableLoopBackCheck” and modify its value to 1. After this a reboot is required.

User Profile Service

Create the User Profile service like you’ve created the others thru Central Admin. Give the correct database names and select the search application pool. After it’s created start up the User profile search and synchronization services on the “Manage Services on server” page. The synchronization service will ask for the credentials of the farm account. After you’ve entered them it will take some time to start. After it’s started you must reset IIS.

To configure the user profile synchronisation go in Central Admin to “Application Management” =>Manage Service Applications and open the User Profile Service application you just created. Click on “Configure a Synchronization connection”

Now lets create a new connection. Fill in the correct info. Give your connection a name. Choose Active Directory and fill in your Forrest name. Just let it auto discover the Domain Controller. The account we will use for the sync is S_SPadsync. Keep the standard port and press the populate containers button. If everything goes well you should see your domain. Press select all and where good to go.

If you want you can add some connection filters like to exclude the disabled users. Because this is a development environment we will not add any filters. If we need them we’ll add them later. Now go back to the User Profile Service application and configure the Synchronization Timer Job. Choose a schedule you like and enable the Timer Job.

Now when you go back to the User Profile Service Application you can start a full synchronization for the first time. To allow the search account to find users you should go back to the Manage services on server page and select the User Profile Service Application. Here you can set the administrators for the application. Here you should add the search account so it can retrieve user info.

Go to the User Profile Service Application page and open Manage User Permissions. If you want you can change here which users have permission to have a MySite.

If you want you can create other service applications to but there are for me the basics you must have.

Just one more PowerShell Script left. This is to integrate the workflowmanager with SharePoint.

Register-SPWorkflowService –SPSite "http://SP2013.RD.local/" –WorkflowHostUri "http://localhost:12290/" –AllowOAuthHttp