SharePoint 2010 Server Scripting: Unattended Powershell Install

November 23, 2009

Anytime I have to do anything more than twice, I start to get a twitch in my left eye which is followed by a strong desire to script it. I grew up doing this with some really ugly, but functional batch files that did anything from updating virus signatures to brushing my dog. As I have been working with SharePoint 2010 I find myself twitching every time I install it. I decided to take today to assemble a PowerShell script to do this work for me so I can do some light reading while it processes (don’t tell my boss…)

If you take a look at this script you will notice a few things:
First, it’s ugly. I’m an IT Pro, not a programmer; cut me some slack.
Second, you will need to change the path of your install files as well as the variables that contain your farm information. The information that you may need to modify prior to running this is shown below in blue. Also, if you are new to PowerShell you will need to set your execution policy for this to execute.

#Execute setup.exe with the setupfarmsilent xml to install SharePoint
& 'C:\install\sp2010_portal\setup.exe' '/config' 'C:\install\sp2010_portal\files\SetupFarmSilent\config.xml' | out-null

#Include the SharePoint cmdlets
Add-PsSnapin Microsoft.SharePoint.PowerShell

#Set the farm variables
$sp_databasename = "MySPFarm_Config"
$sp_databaseserver = "MySQLServer\InstanceName"
$sp_passphrase = (ConvertTo-SecureString "MySuperSecretPassphrase" -AsPlainText -force)
$sp_password = (ConvertTo-SecureString "MySuperSecretPassword" -AsPlainText -force)
$sp_username = "MyDomain\MySPFarmUser"

#Clean up the credentials
$sp_credentials = New-Object System.Management.Automation.PsCredential $sp_username,$sp_password

#Execute the config wizard
New-SPConfigurationDatabase -DatabaseName $sp_databasename -DatabaseServer $sp_databaseserver -Passphrase $sp_passphrase -FarmCredentials $sp_credentials

#Provision a Central Administration Site
New-SPCentralAdministration -WindowsAuthProvider "NTLM"
VN:F [1.9.22_1171]
Rating: 8.0/10 (3 votes cast)

Leave a Reply

Your email address will not be published. Required fields are marked *

Let's make sure you're human first: *

  1. September 8th, 2010 at 15:14 | #1

    Thanks for this tutorial dude, its very handy for me!

  2. June 4th, 2011 at 11:49 | #2

    Glad I’ve finally found soehmtnig I agree with!

  3. Waseem
    October 16th, 2013 at 04:18 | #3

    Hi, can you provide me with the Config.xml file please?

  1. December 15th, 2010 at 01:22 | #1
    SharePointEduTech The 12 Days of SharePoint Christmas Day 4
  2. September 3rd, 2013 at 13:58 | #2
    SharePoint 2010 Powershell Scripting: Unattended WebApp Install
  3. September 3rd, 2013 at 13:58 | #3
    SharePoint 2010 Installation using PowerShell: 2010 Beta Product Key Required for SP2010 Server