Last Update: Sep 04, 2024 | Published: Apr 23, 2013
Installing SharePoint 2013 can be a relatively simple process, but there are a few “gotchas” waiting for the uninitiated. I”ll focus on one of these gotchas in this article, which describes the process of creating the SharePoint 2013 farm creation using PowerShell.
The farm configuration is typically performed right after installation of the first SharePoint server in a farm. In fact, by default the farm configuration wizard will kick off with the last screen of the SharePoint 2013 Server Installation Wizard.
Reasons to avoid using the built-in SharePoint Products Configuration Wizard:
Reasons to use PowerShell to perform the SharePoint configuration:
This article starts from the point right after you’ve performed the SharePoint 2013 Server installation. Since you should already be installed and ready to configure the farm, I’ll leave the requirements for service accounts and necessary permissions for another article. However, if you need a review of those items, check out the Deployment Guide for SharePoint 2013 from Microsoft.
Also, the commands we work with will be part of the SharePoint module for PowerShell. This means you either need to run the SharePoint command shell, or you’ll need to import the commands to perform SharePoint administration with PowerShell (in either a standard PowerShell session or the ISE).
$SPAddin If (!(Get-PSSnapin | Where-Object –Property “Name” -eq –Value $SPAddin)) | ` {Add-PSSnapin $SPAddin}
To perform the basic farm configuration, I’ll be using a few service accounts as examples. The number of service accounts you will use may be very different based on your security requirements and SharePoint architecture.
A basic farm installation can be done through PowerShell using the SharePoint PS-Snapin.
While making every configuration for a SharePoint farm is out of scope for this article, here are the PowerShell commands that will make your SharePoint farm initialization easy and uniform:
New-SPConfigurationDatabase actually creates the farm by turning on the Configuration Database. If SharePoint was creating the farm through the wizard instead of PowerShell, the database would be called SharePoint_Config.
However, by using this command you will be able to change the database name so that it will be consistent with the rest of the naming structure. This also makes it very easy to distinguish between different farms that are using the same SQL server, for instance, a “SP2013_SharePoint_Config” and a “SP2010_SharePoint_Config”.
You’ll need to pass a few parameters into the command. You have to specify the database instance location, and you’ll have to name the Configuration Database and the Central Admin Content database. Finally, you have to specify a farm passphrase for the farm and provide credentials of the Farm Administrator account.
This is an example that you can use to create the SharePoint Farm databases:
New-SPConfigurationDatabase -DatabaseServer $DBAlias ` -DatabaseName “$Prefix_SharePoint_Config” ` -AdministrationContentDatabaseName “$Prefix_Admin_Content” ` -Passphrase $Passphrase ` -FarmCredentials $SPFarm
Next, you’ll need to set up a Central Administration site. This is a simple configuration step — all you need to do is set a port for the Central Administration site. However, if you’re going to use Kerberos authentication instead of NTLM, you’ll need to specify it with the -WindowsAuthProvider parameter. You can also specify NTLM as the Authentication Provider, but you don’t need to because omitting it is the same as specifying NTLM.
New-SPCentralAdministration -Port $CentralAdmin -WindowsAuthProvider "NTLM"
Install-SPHelpCollection –All
Initialize-SPResourceSecurity
Install-SPService
Install-SPApplicationContent
Install-SPFeature -AllExistingFeatures -Force
Now that you’ve gotten the farm set up and the first databases configured, there are some other commands that you should consider.
New-SPWebApplication: The first part of creating a Web Application with PowerShell is to create the web application and application pool. You have to specify an application pool name. If the application pool doesn’t exist yet, you’ll have to specify an account to run the application pool as by using the Get-SPManagedAccount cmdlet. You’ll also have to name the web application.
–DatabaseName: You should also take this opportunity to specify the name of the content database used by taking advantage of the optional –DatabaseName parameter. If you omit this parameter, it will be set to the default WSS_Content_<GUID>, which would look much better as SP2013_User_Profile_Content than WSS_Content_HugeRandomStringOfCharacters.
Other parameters that you may be looking for are there, too: You can set the authentication method (again, NTLM is used if this isn’t specified), the port, the host header, the path to the virtual directory and the load balanced Url.
Absolutely every aspect of SharePoint administration can be performed with PowerShell. In some cases, you may find it easier to complete these tasks from with Central Administration. However, in most cases using PowerShell provides the most ability to administer SharePoint in consistent, reliable, and repeatable methods. Using PowerShell is also the way to configure your SharePoint farm so that the databases are consistent and easy to read.
So, if you’ve been taking the easy road and working your way through the SharePoint Products Configuration Wizard to install your SharePoint farm — stop! Roll up your sleeves, take a few extra minutes to figure out the PowerShell commands and setup your farm exactly the way you want it.