SharePoint 2010 Server Scripting: Unattended Powershell Install

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)

About Fpweb.net Crew

Our business is centered on bringing enterprise-class strategy, support, and security to your hosted or managed platforms no matter where you choose to deploy your environment. We specialize in providing managed services, cyber security, and expert, USA-based, 24/7 Absolute SupportĀ® on-premises, or in any cloud.
This entry was posted in PowerShell and tagged , , , , . Bookmark the permalink.

6 Responses to SharePoint 2010 Server Scripting: Unattended Powershell Install

  1. Steve says:

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

  2. Pingback: SharePointEduTech The 12 Days of SharePoint Christmas Day 4

  3. Janelle says:

    Glad I’ve finally found soehmtnig I agree with!

  4. Pingback: SharePoint 2010 Powershell Scripting: Unattended WebApp Install

  5. Pingback: SharePoint 2010 Installation using PowerShell: 2010 Beta Product Key Required for SP2010 Server

  6. Waseem says:

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

Leave a Reply

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

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