<#====================================================================

Copyright © 2015, September. Michael Pomfret

Creating a new Server Farm

The script only targets the server you are running the script on

and does the following:

-Creates the SharePoint Configuration content database.

-Creates the SharePoint Administration content database.

-Install SharePoint services

-Install SharePoint features

-Copies shared application data to existing Web application folders.

====================================================================#>

Write-Host “- Enabling SP PowerShell cmdlets…”

If ((Get-PsSnapin |?{$_.Name -eq “Microsoft.SharePoint.PowerShell”})-eq $null)

{

Add-PsSnapin Microsoft.SharePoint.PowerShell | Out-Null

}

Write-Host “SharePoint 2013 – Creating a new Server Farm…”

$SecPassPhrase = ConvertTo-SecureString $PassPhrase –AsPlaintext –Force

$FarmAccPWD = ConvertTo-SecureString $FarmPassword –AsPlaintext –Force

$cred_FarmAcc = New-Object System.Management.Automation.PsCredential $FarmAcc,$FarmAccPWD

Start-SPAssignment -Global | Out-Null

Write-Host “====================================================================”

Write-Host “- Creating configuration database…”

Write-Host “- Using DBServer…”$DBServer

Write-Host “- Using Central Admin Content DB…”$CentralAdminContentDB

Write-Host “- Using Port…”$CentralAdminPort

Write-Host “====================================================================”

Write-Host

New-SPConfigurationDatabase –DatabaseName “$ConfigDB” –DatabaseServer “$DBServer” –AdministrationContentDatabaseName “$CentralAdminContentDB” –Passphrase $SecPassPhrase –FarmCredentials $cred_FarmAcc

Write-Host “- Installing Help Collection…”

Install-SPHelpCollection -All

Write-Host “- Securing Resources…”

Initialize-SPResourceSecurity

Write-Host “- Installing Services…”

Install-SPService

Write-Host “- Installing Features…”

$Features = Install-SPFeature –AllExistingFeatures -Force

Write-Host “- Creating Central Admin…”

$NewCentralAdmin = New-SPCentralAdministration -Port $CentralAdminPort -WindowsAuthProvider “NTLM”

Write-Host “- Waiting for Central Admin to provision…”-NoNewline

Write-Host ” Created!”

Write-Host “- Installing Application Content…”

Install-SPApplicationContent

Stop-SPAssignment -Global | Out-Null