Why should we use PowerShell to create a SharePoint farm rather than the nice SharePoint products configuration wizard? Because SharePoint Products configuration wizard creates Central Administration database names with GUIDs.
Create SharePoint 2013 farm using PowerShell:
How to start? Follow these steps to create a SharePoint farm using PowerShell.
Step 1: Install SharePoint binaries on each server to your SharePoint 2013 farm. On completion: you will be asked to run the “SharePoint Products Configuration Wizard” – Do not run the wizard!
Step 2: Logon to the server where you would like to host the SharePoint Central Administration site. Right-click on “SharePoint 2013 Management Shell” and select “Run as administrator”. The shell will give “Local farm is not accessible”, This is expected as we have not created the farm yet. Proceed to execute the cmdlets below to create SharePoint 2013 farm using PowerShell.
SharePoint 2013 create new farm using PowerShell
Set the values at the #Configuration Settings section below and run these PowerShell commands. Enter the password for the Farm account when prompted.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Configuration Settings $DatabaseServer = "SP13_SQLSrv" $ConfigDatabase = "Intranet_Farm_Config" $AdminContentDB = "Intranet_Farm_Content_Admin" $Passphrase = "2FJlsXghFsas5vdJJKEXXwWF" $FarmAccountName = "Crescent\SP13_Farm" #Get the Farm Account $FarmAccount = Get-Credential $FarmAccountName $Passphrase = (ConvertTo-SecureString $Passphrase -AsPlainText -force) #Create SharePoint Farm Write-Host "Creating Configuration Database and Central Admin Content Database..." New-SPConfigurationDatabase -DatabaseServer $DatabaseServer -DatabaseName $ConfigDatabase -AdministrationContentDatabaseName $AdminContentDB -Passphrase $Passphrase -FarmCredentials $FarmAccount Write-Host "Installing SharePoint Resources..." Initialize-SPResourceSecurity Write-Host "Installing Farm Services ..." Install-SPService Write-Host "Installing SharePoint Features..." Install-SPFeature -AllExistingFeatures Write-Host "Creating Central Administration..." New-SPCentralAdministration -Port 8080 -WindowsAuthProvider NTLM Write-Host "Installing Help..." Install-SPHelpCollection -All Write-Host "Installing Application Content..." Install-SPApplicationContent Write-Host "SharePoint 2013 Farm Created Successfully!"
Step 3: Connect Rest of the Servers to the Farm:
Once you have created the SharePoint farm and SharePoint Central Administration site, You can connect the rest of the servers to SharePoint Farm either using the PowerShell cmdlet
PowerShell to Add Servers to the SharePoint 2013 Farm:
Close and reopen the SharePoint 2013 Management Shell and run these PowerShell cmdlets.
Connect-SPConfigurationDatabase -DatabaseName "Intranet_Farm_Config" -DatabaseServer "SP13_SQLSrv" -Passphrase (ConvertTo-SecureString "2FJlsXghFsas5vdJJKEXXwWF" -AsPlaintext -Force) Write-Host "Installing SharePoint Resources..." Initialize-SPResourceSecurity Write-Host "Installing Farm Services ..." Install-SPService Write-Host "Installing SharePoint Features..." Install-SPFeature -AllExistingFeatures Write-Host "Installing Help..." Install-SPHelpCollection -All Write-Host "Installing Application Content..." Install-SPApplicationContent Write-Host "Added the Server to Farm Successfully!"
Don’t forget the change the parameter values according to your environment!
Alternatively, You can use PSConfig wizard and choose “Connect to an existing server farm” and then complete the wizard!
This avoids GUIDs in the SharePoint Admin database and gives you the flexibility to name your SharePoint Central Admin database.
In case you already created the SharePoint farm using SharePoint 2013 GUI wizard, and you ended up with database names that have GUID’s use this article to remove the GUIDs from SharePoint Central Admin database: How to remove GUID from SharePoint Central Admin Database