SharePoint 2013 – Create Farm with Powershell

Whether, you are like me and hate configuration wizard or simply you are in need of control of your configuration, for sure you are considering using PowerShell for installing /configuring your SharePoint farm.

Just as with SharePoint 2010, after installation of the binaries, simply by un-checking the “Configuration Wizard” checkbox you would have the option to create and configure the Farm yourself as well as creating Service Applications to follow your exact specifications for consistent database naming rules (just as your Database Administrator would require it in a Production environment)!

So the 1st part of a script I’ve been creating and using for installing hundreds of farms for the past years, with no changes at all, I’ve created my SharePoint 15 RTM farm!

Feel free to use it at will (Service Applications will follow)!

1. Launch the PowerShell ISE (in Administrator mode)!

2. Paste in the Script and execute it

$configType=read-host"Do you wish to create a new farm? (Y/N)"
if ($ConfigType-eq"N") 
{
 $DatabaseServer=read-host"Preparing to join existing farm. Please specify the name of your SQL Server";
$ConfigDB=read-host"Next, specify the name of your Farm Configuration Database:"
$Passphrase=read-host"Finally, please enter your Farm passphrase"-assecurestring
}
else { 
$DatabaseServer=read-host"Preparing to create a new Farm. Please specify the name of your SQL Server (ex SERVER or SERVER\INSTANCE[,PORT] or SQL Alias)";
$DatabasePrefix=read-host"Please specify a Prefix for databases (ex. SP)";
$ConfigDB=$DatabasePrefix+"_Config_Farm";
$AdminContentDB=$DatabasePrefix+"_Content_CentralAdmin";
Write-Host"Please enter the credentials for your Farm Service Account (ex. DOMAIN\SPFarmService)";
$FarmAcct=Get-Credential;
$Passphrase=read-host"Enter a secure Farm passphrase (must meet password complexity requirements)"-assecurestring;
$Port=read-host"Enter a port number for the Central Administration Web App (e.g. 9999)";
$Authentication=read-host"Finally, specify your authentication provider (NTLM/Kerberos)"; 
}
if ($ConfigType-eq"N") {
if((Get-PSSnapin|Where {$_.Name -eq"Microsoft.SharePoint.PowerShell"}) -eq$null) {
Add-PSSnapinMicrosoft.SharePoint.PowerShell;
}
Connect-SPConfigurationDatabase-DatabaseName$ConfigDB-DatabaseServer$DatabaseServer-Passphrase$Passphrase
}
else {
if((Get-PSSnapin|Where {$_.Name -eq"Microsoft.SharePoint.PowerShell"}) -eq$null) {
Add-PSSnapinMicrosoft.SharePoint.PowerShell;
}
Write-Host"Your SharePoint Farm is being created and configured..."
New-SPConfigurationDatabase-DatabaseName$ConfigDB-DatabaseServer$DatabaseServer-AdministrationContentDatabaseName$AdminContentDB-Passphrase$Passphrase-FarmCredentials$FarmAcct
}
Write-Host -ForegroundColorYellow"Securing access to resources";
Initialize-SPResourceSecurity
Write-Host -ForegroundColorYellow"Provisioning Farm Services";
Install-SPService
Write-Host -ForegroundColorYellow"Installing all features";
Install-SPFeature -AllExistingFeatures
Write-Host -ForegroundColorYellow"Creating Central Administration Web application";
New-SPCentralAdministration -Port$Port-WindowsAuthProvider$Authentication
Write-Host -ForegroundColorYellow"Installing default Help collection";
Install-SPHelpCollection -All
Write-Host-ForegroundColorYellow"Installing application content";
Install-SPApplicationContent
Write-Host -ForegroundColorGreen"SharePoint 15 Farm been created!"
$disableLoopbackCheck =read-host"Do you wish to disable loopback check [Optional]? (Y/N)"
if ($disableLoopbackCheck-eq"Y") 
{
New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa-Name"DisableLoopbackCheck"  -value"1"-PropertyTypedword
Write-Host -ForegroundColorGreen"Loopback Check has been disabled!"
}
Write-Host -ForegroundColorGreen"SharePoint Farm has been created!" 
Advertisements

2 responses to “SharePoint 2013 – Create Farm with Powershell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s