SharePoint 2010 Server Scripting: Unattended Powershell Install
Published by Chris Schwab 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"