Provisioning Central Admin Config DB, Content DB, and then SharePoint Service Apps for SharePoint 2013 Foundation

Have you ever had a blast from the past and looked for a script on configuring SharePoint 2013 Foundation?

 

Before you run the scripts below, you need to install the binaries.  Todd Klindt has an awesome blog post where you can get the downloads -> http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=346

 

Once, you’ve downloaded the binaries, installed them and patched to whichever CU, you can use these scripts

 

Create Central admin config db and content db

Set-ExecutionPolicy Unrestricted

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue


Write-Host "When prompted for credentials, give SharePoint the farm account, not the install account that you are signed in with, then provide the passphrase, note: you will not be prompted for passPhrase if it is baked into the script" -ForegroundColor green

New-SPConfigurationDatabase -DatabaseName SharePoint_Config -DatabaseServer SharePointSQL -Passphrase (ConvertTo-SecureString "Sh@r3PointOnPrem!sNotK!ng" -AsPlainText -Force) -FarmCredentials (Get-Credential) -AdministrationContentDatabaseName SharePoint_AdminContent

$CAPort = 5000

$CAAuth = "NTLM"

Install-SPHelpCollection -All

Initialize-SPResourceSecurity

Install-SPService

Install-SPFeature -AllExistingFeatures

New-SPCentralAdministration -Port $CAPort -WindowsAuthProvider $CAAuth

Install-SPApplicationContent

New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -value "1" -PropertyType dword

## Note you might not have an SCP in your domain, so you may want to exclude the next two lines ##

$ServiceConnectionPoint = get-SPTopologyServiceApplication | select URI

Set-SPFarmConfig -ServiceConnectionPointBindingInformation $ServiceConnectionPoint -Confirm: $False

Write-Host "Make sure to register the managed accounts for Service Apps and for Web Content before continuing with the 2013Install script" -ForegroundColor Green -BackgroundColor Yellow

 

 

 

After that script finishes, add your managed accounts, using New-SPManagedAccount for the account used in creating the service apps

Create Foundation Service Apps

#####################################################
# This script replicates most of the functionality found in the SharePoint Products Configuration Wizard with the EXCEPTION of the USER PROFILE SERVICE#####################################################
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

## Settings you may want to change ##
$databaseServerName = "SharePointSQL" #assumes you're using a SQL Alias configured with cliconfg.exe
$saAppPoolName = "SharePoint Hosted Services"
$appPoolUserName = "Phmain\2013SP_ServApp_AP" #This is the service application pool account it is not the farm admin account for Timer and Central admin, sometimes calle#d the farm account, it is not the setup account, or install account


## Service Application Service Names ##
$appManagement = "App Management Service"
$bcsSAName = "Business Data Connectivity Service"
$stateSAName = "State Service"
$secureStoreSAName = "Secure Store Service"
$usageSAName = "Usage and Health Data Collection Service"


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

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

$appPoolAccount = Get-SPManagedAccount -Identity $appPoolUserName -EA 0

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 -EA 0 > $null

}

Write-Host "Creating Usage Service and Proxy…"
$serviceInstance = Get-SPUsageService
New-SPUsageApplication -Name $usageSAName -DatabaseServer $databaseServerName -DatabaseName "Usage" -UsageService $serviceInstance > $null

Write-Host "Creating BCS Service and Proxy…"
New-SPBusinessDataCatalogServiceApplication -Name $bcsSAName -ApplicationPool $saAppPoolName -DatabaseServer $databaseServerName -DatabaseName "BusinessDataCatalog" > $null

Get-SPServiceInstance | where-object {$_.TypeName -eq "Business Data Connectivity Service"} | Start-SPServiceInstance > $null

Write-Host "Creating State Service and Proxy…"
New-SPStateServiceDatabase -Name "StateService" -DatabaseServer $databaseServerName | New-SPStateServiceApplication -Name $stateSAName | New-SPStateServiceApplicationProxy -Name "$stateSAName Proxy" -DefaultProxyGroup > $null

Write-Host "Creating Secure Store Service and Proxy…"
New-SPSecureStoreServiceapplication -Name $secureStoreSAName -Sharing:$false -DatabaseServer $databaseServerName -DatabaseName "SecureStoreServiceApp" -ApplicationPool $saAppPoolName -auditingEnabled:$true -auditlogmaxsize 30 | New-SPSecureStoreServiceApplicationProxy -name "$secureStoreSAName Proxy" -DefaultProxygroup > $null

Get-SPServiceInstance | where-object {$_.TypeName -eq "Secure Store Service"} | Start-SPServiceInstance > $null

Write-Host "Creating App Management Service…"
Get-SPServiceInstance | where{$_.GetType().Name -eq "AppManagementServiceInstance"} | Start-SPServiceInstance
$appAppSvc = New-SPAppManagementServiceApplication -ApplicationPool $saAppPoolName -Name $appManagement -DatabaseName "AppmanagementDB"
$proxyAppSvc = New-SPAppManagementServiceApplicationProxy -ServiceApplication $appAppSvc

Write-Host "Creating Subscriptions Settings Service…"
$SvcApp = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $saAppPoolName -Name "Subscription Settings Service Application" -DatabaseName "SubscriptionSettingsdb" -DatabaseServer $databaseServerName

$SvcAppProxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $SvcApp
Get-SPServiceInstance | where{$_.TypeName -eq "Microsoft SharePoint Foundation Subscription Settings Service"} | Start-SPServiceInstance

Write-Host "Script completed, run the white wizard to install search"
############################################## End Script


#Now proceed to manually configuring your various service applications (e.g. the Secure Store Service and BDC Service)

 

 

Then after you’ve finished with those two scripts, you can append _admin/adminconfigintro.aspx?scenarioid=adminconfig&welcomestringid=farmconfigurationwizard_welcome to your central administration URL to enter the wizard to create the search service application.  It’s not supported to create a search service application for foundation with powershell.

 

Happy SharePointing!