How to Create SharePoint 2016 Farm using PowerShell?
Creating SharePoint 2016 farm using PowerShell is almost as same as in its previous version. In SharePoint 2016 there is an additional parameter -LocalServerRole added as SharePoint 2016 introduced MinRoles.
Pre-Requisites:
Step 1: Install SharePoint 2016 prerequisites and binaries to each server in your proposed SharePoint 2016 farm.
On completing the installation, Uncheck "Run the SharePoint Products Configuration Wizard now" and close the wizard.
Step 2: PowerShell Script to Create SharePoint 2016 Farm:
Save the below script as "Create-Farm.ps1" or something like that, change the configuration settings parameters as per your environment. Open SharePoint 2016 Management Shell as Administrator, and run the script. You'll see
"The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered." error for the first time, which is quite normal, since we have not created the Farm yet! proceed running the script.
Add Additional Servers to the SharePoint 2016 Farm:
Once you are done with the creation of the SharePoint 2016 farm from first server, You can connect rest of the servers to the Farm either using SharePoint products configuration wizard or with PowerShell.
Open SharePoint products configuration wizard and choose "Connect to an existing server farm" and run through the wizard! Select the server MinRole as per your topology.
Join Additional Server to the SharePoint 2016 farm using PowerShell:
If you prefer PowerShell way to add an additional server to the farm, use this PowerShell script.
Pre-Requisites:
- SQL Server is already installed and ready to use.
- You have created a Farm account for SharePoint 2016.
- You have logged in to the server (Setup account) which has Administrator access on all SharePoint servers and DB_Creator, Security_Admin Server roles in SQL Server.
Step 1: Install SharePoint 2016 prerequisites and binaries to each server in your proposed SharePoint 2016 farm.
On completing the installation, Uncheck "Run the SharePoint Products Configuration Wizard now" and close the wizard.
Step 2: PowerShell Script to Create SharePoint 2016 Farm:
Save the below script as "Create-Farm.ps1" or something like that, change the configuration settings parameters as per your environment. Open SharePoint 2016 Management Shell as Administrator, and run the script. You'll see
"The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered." error for the first time, which is quite normal, since we have not created the Farm yet! proceed running the script.
#Configuration Settings $DatabaseServer = "SP16-SQL" $ConfigDatabase = "Intranet_Farm_Config" $AdminContentDB = "Intranet_Farm_Content_Admin" $Passphrase = "2FJlsXghFsas5vdJJKEXXwWF" $FarmAccountName = "Crescent\Sp2016admin" $ServerRole="SingleServerFarm" #Get the Farm Account Credentials $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 -LocalServerRole $ServerRole $Farm = Get-SPFarm -ErrorAction SilentlyContinue -ErrorVariable err if ($Farm -ne $null) { 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 2016 -WindowsAuthProvider NTLM Write-Host "Installing Help..." Install-SPHelpCollection -All Write-Host "Installing Application Content..." Install-SPApplicationContent Write-Host "SharePoint 2016 Farm Created Successfully!" }Once the script completed successfully, You'll see farm created successfully message. Here I've used "SingleServer" as MinRole. You can adjust it based on your requirement.
Alternatively, You can create SharePoint Farm (Run script til line#15) and then Run Products configuration wizard to complete the rest of the steps in farm creation.
Add Additional Servers to the SharePoint 2016 Farm:
Once you are done with the creation of the SharePoint 2016 farm from first server, You can connect rest of the servers to the Farm either using SharePoint products configuration wizard or with PowerShell.
Open SharePoint products configuration wizard and choose "Connect to an existing server farm" and run through the wizard! Select the server MinRole as per your topology.
Join Additional Server to the SharePoint 2016 farm using PowerShell:
If you prefer PowerShell way to add an additional server to the farm, use this PowerShell script.
$ServerRole="Application" #"Custom","WebFrontEnd","Application","DistributedCache","SingleServerFarm","Search","ApplicationWithSearch","WebFrontEndWithDistributedCache" Connect-SPConfigurationDatabase -DatabaseServer $DBServer -DatabaseName $DBName -PassPhrase $Passphrase -LocalServerRole $ServerRole 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 "Joined the Server to Farm Successfully!"
If you don't want the server to host Distributed cache, use the parameter: -SkipRegisterAsDistributedCacheHost and the end!
Related post: How to Create SharePoint 2013 farm using PowerShell
Great Work you do man. Very much appreciate it :)
ReplyDeleteThank you so much for sharing this script. Its pretty clean and neat, I'm able to pickup although I'm new to SharePoint. Kudos.
ReplyDeleteSekar
I don't find the Custom Ribbon on the top in the Central Admin screen ? what could be the issue?Please advise
ReplyDeleteTnx alot for useful post
ReplyDeleteI ran the script and get cannot bind parameter 'passphrase' cannot convert the value of type system.string to type system secure string? the under Get-farm a positional parameter cannot be found that accepts argument if?
ReplyDeleteUse $Passphrase instead of "$SecurePassphrase"
DeleteThanks for your useful post. I may did a mistake running your script... I was logged in as SP_Admin (because the only local Admin and RDP user for this machine) and ran your script. I named the user SP_Farm as Farm Account Name. The config itself was successfull and I can access the Central Administration partyl with the SP_Farm account. But I cannot do the most settings. Either they are greyed out or I get "Sorry, this page was not shared with you yet". The SP_Admin user can do everything I want...
ReplyDeleteI see the SP_Farm account as member in farm administrators group. Where's the fault? I don't get it...
Disable Internet Explorer Enhanced Security and Add a Full control Policy to your SP_Admin Account!
DeleteHello,
ReplyDeleteI have a question: does the farm config steps' order matter ? I mean, you followed the following order in your script :
Initialize-SPResourceSecurity > Install-SPService > Install-SPFeature > New-SPCentralAdministration > Install-SPHelpCollection > Install-SPApplicationContent
But I found other articles/scripts doing the same but with different order as follows :
Install-SPHelpCollection > Initialize-SPResourceSecurity > Install-SPService > Install-SPFeature > New-SPCentralAdministration > Install-SPApplicationContent
so ?
Changing the order of Help File collection doesn't do any harm!
DeleteHi Salaudeen - 1) Is this the same for installing SharePoint 2019 & 2) Do you run the script from the folder containing the SharePoint setup/binaries files?
ReplyDelete