Last modified at 3/15/2014 9:24 AM by Koen Zomers

It is possible to use the magic of PowerShell to configure a new SharePoint farm without having to use the SharePoint configuration wizard. This can be done using the following easy steps. These steps are valid for both SharePoint 2010 as well as SharePoint 2013.

Generic steps

  1. Create two accounts within your Active Directory which will be used for SharePoint:

    ​Setup accountAdd this domain account with normal user rights in the domain to the local administrators group on each SharePoint server.

    In the SQL server you're going to host your SharePoint databases on, assign this account the dbcreator and securityadmin sql roles.
    ​Farm account
    This should just be a normal domain account with normal user rights in the domain. The account will be used when setting up the new farm using the New-SPConfigurationDatabase command below and will function as the IIS pool account for Central Administration, will host the SharePoint Timer Service and the SharePoint User Code Host (sandboxed solutions) services.

    The appropriate rights in SQL server will automatically be assigned to this account when running the New-SPConfigurationDatabase PowerShell command under the credentials of the setup account created above.

  2. Once you've created the accounts, log in to the server using the setup account you have created at step 1 and continue the steps below.

  3. Mount the SharePoint 2010 or 2013 ISO and install the prerequisites using the prerequisiteinstaller.exe

    SharePoint_Install_PowerShell_PrerequisitesInstaller.png

  4. Once done, run setup.exe to install the SharePoint 2010 or 2013 files onto your server. Go through the wizard accepting the defaults until the files are installed. You do not need to run the SharePoint Configuration Wizard which will be started after installation by default. Just close it again as the PowerShell commands below will do exactly the same as the wizard, but then in a controlled manner.

  5. Create a SQL database alias using one of the methods described at this page

  6. Optional: disable the local loopback check by running the following PowerShell command:

    New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck"  -value "1" -PropertyType dword

Based on installing a new SharePoint farm or adding a server to an existing farm, follow the steps under the appropriate heading below.

Configuring a new SharePoint farm

Open a PowerShell window as an administrator and copy in the following italic commands one by one or download this PowerShell script containing all the commands:

Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

New-SPConfigurationDatabase –DatabaseName "SharePoint15_Config" –DatabaseServer "sql-db-alias" –AdministrationContentDatabaseName “SharePoint15_Sites_AdminContent” –Passphrase (ConvertTo-SecureString "yourpassphrase" –AsPlaintext –Force) –FarmCredentials (Get-Credential)

At the credential box, enter your SharePoint farm account credentials.

Install-SPHelpCollection -All

Initialize-SPResourceSecurity

Install-SPService

Install-SPFeature –AllExistingFeatures

New-SPCentralAdministration -Port 8000  -WindowsAuthProvider "NTLM"

Install-SPApplicationContent

Adding a server to an existing SharePoint farm

Open a PowerShell window as an administrator and copy in the following commands one by one or download this PowerShell script containing all of the commands:

Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Connect-SPConfigurationDatabase -DatabaseServer "sql-db-alias" -DatabaseName "SharePoint15_Config" -Passphrase (ConvertTo-SecureString "yourpassphrase" -AsPlainText -Force)

Initialize-SPResourceSecurity

Install-SPService

Install-SPFeature -AllExistingFeatures

Removing a server from an existing SharePoint farm

In case you wish to remove a SharePoint server from an existing farm, run the following PowerShell command:

Disconnect-SPConfigurationDatabase