SharePoint 2010 Server Scripting: Unattended Powershell Install

Published by on November 23rd, 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"
 

About Chris Schwab

Chris Schwab has written 21 posts in this blog.

If you’re ever faced with a particularly challenging SharePoint query, this is the man to turn to. Truly a SharePoint sponge, Chris spends most of his time soaking up the latest in the SharePoint community, tinkering around on his hosted SharePoint 2010 site and composing PowerShell scripts. A fan of Joel McHale and the lore of Marvel Comics, this new age mountain man can be most often spotted outdoors, rehabbing trails for the Ozark Trail Association, camping or completing the newest grueling exercises from CrossFit. Follow Me on Google+

VN:F [1.9.22_1171]
Rating: 8.0/10 (3 votes cast)

 
  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
  2. September 3rd, 2013 at 13:58 | #2
  3. September 3rd, 2013 at 13:58 | #3

Leave a Reply

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


seven × = 35

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>