Skip navigation

SharePoint is So Last Month--And Scripted Configuration: Dan Holme at TechEd 2010

A script offering the advantage of an automated configuration method

Greetings from New Orleans!  The city known for celebration and rebirth is hosting Microsoft TechEd 2010, and 6,000 or so of my closest friends converged on the city for a week of … um … professional development …. Yes!  That’s what I’m seeing happening on Bourbon Street—professional development!

Seriously, though, people are packing into the convention center for hundreds of sessions across every Microsoft technology, but one of the most amazing things to me is that SharePoint Server 2010, which launched less than a month ago and is part of Office that hits the global market this week, is not even close to the center of attention.  It’s “so last month,” I guess!  Everything seems to be about the cloud (which of course includes SharePoint as well as many other MS products) and new products like Windows InTune and Office Communications Server.  Fundamental technologies like Active Directory are barely getting a nod.  I look forward to upcoming events that are more focused in their content—TechEd may have gotten too big to be able to be “everything to everyone,” particularly when it’s less than half the size it was just a few years ago.

I’ve also been completely consumed by a SharePoint content project that is a case study in Murphy’s Law.  Nothing has gone right on the project for five months.  Very little of that has anything to do with SharePoint 2010 itself, though.  I continue to be impressed with the changes in the product, both big and small.  I’m definitely a believer!  But because the project has been plagued with challenges, one thing I’ve had to do is re-deploy SharePoint about… um… a million times.  

In the process, I’ve become a master of scripting the installation and configuration of the farm I’m working with.  So this week, I thought I’d share some of the fruits of my work—a script that completely automates the “configuration” phase of installation that you would perform manually by using the SharePoint Products Configuration Wizard.  This script is a derivative of a script on TechNet, but that script has some bugs in it that I’ve squashed.  Keep reading (at our website) to get the script.

There are a couple of big advantages of scripting configuration.  First, you have a “document” of the settings that were used.  Second, you can easily test the script in a lab before running in production.  Third, you can gain consistency across servers.  

The script below is a Windows PowerShell script that can be run on a SharePoint 2010 server.  SharePoint 2010 requires PowerShell, so by the time you’ve installed the “bits” of SharePoint (setup.exe), PowerShell will be there.  All you have to do is change the variables in the top of the script, then run it. The script below is designed to get the first server in the farm up and running.  It creates a new farm.  You’ll want to use other scripts to automate the configuration of additional servers in the farm, and to deploy service applications across the farm. In future newsletters, we’ll cover those steps.

This script is a derivative of a script on TechNet, but that script has (or had, until I reported them) some bugs.  I’ve also cleaned up the script to make it clearer how it’s working, and how to configure it.  Enjoy!

# Configure SharePoint
# 8 June 2010 Dan Holme ([email protected])
# This script configures SharePoint Server 2010 
# on the first server in a farm
# The script is to be run after installing SharePoint (setup.exe)
# which itself can be automated by using config.xml.
# The script uses the same settings--and to the same effect--as the wizard-driven
# SharePoint 2010 Products Configuration Wizard.
# But gives you the advantage of an automated configuration method,
# and of defining the Admin database name, which cannot be specified in the UI.
# The script is a derivative of the TechNet script
# However this script fixes a bug and tidies up some code

# ---------------------------------------------------------------------------------
# Settings to change

$FarmAccount       = "CONTOSO\SP_Farm"
$ConfigDBName      = "SharePoint_Config"
$AdminDBName       = "SharePoint_AdminContent"
$DBServer          = "SP2010-WFE1"

# Central Administration
$CAPort            = "9999"
$WinAuthProvider   = "NTLM"

# Security-sensitive values are prompted, rather than hard-coded

Write-Host "Please specify the SharePoint Farm account credentials"

$FarmCredential    = Get-Credential $FarmAccount

$Passphrase        = Read-Host -Prompt "Please enter the farm passphrase" -AsSecureString

# To hard code:    = ConvertTo-SecureString "<password>" –AsPlaintext –Force
# but not recommended to hard code a password in a production environment

# ---------------------------------------------------------------------------------

if (\\[String\\]::IsNullOrEmpty($FarmCredential))
    Write-Error "You must enter a Farm Administrator's user name and password"
if ($Passphrase.Length -eq 0)
    Write-Error "You didn't enter a farm passphrase."

# ---------------------------------------------------------------------------------

$err = $null

Write-Host "Please wait..."
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue

Write-Host "\\[1/9\\] Creating SharePoint configuration database..." 
New-SPConfigurationDatabase -DatabaseName $ConfigDBName  -DatabaseServer $DBServer -AdministrationContentDatabaseName $AdminDBName -FarmCredentials $FarmCredential -Passphrase $Passphrase -ErrorVariable err

Write-Host "\\[2/9\\] Verifying farm creation..." 
$spfarm = get-spfarm

if ($spfarm -ne $null) \\{
    Write-Host "\\[3/9\\] Securing SharePoint resources..." 
    Initialize-SPResourceSecurity -ErrorVariable err

    if (\\[String\\]::IsNullOrEmpty($err) -eq $true) \\{
        Write-Host "\\[4/9\\] Installing services..." 
        Install-SPService -ErrorVariable err

        if (\\[String\\]::IsNullOrEmpty($err) -eq $true) \\{
            Write-Host "\\[5/9\\] Installing features..." 
            Install-SPFeature -AllExistingFeatures -ErrorVariable err

            if (\\[String\\]::IsNullOrEmpty($err) -eq $true) \\{
                Write-Host "\\[6/9\\] Provisioning Central Administration..." 
                New-SPCentralAdministration -Port $CAPort -WindowsAuthProvider $WinAuthProvider -ErrorVariable err

                if (\\[String\\]::IsNullOrEmpty($err) -eq $true) \\{
                    Write-Host "\\[7/9\\] Installing Help..." 
                    Install-SPHelpCollection -All -ErrorVariable err

                    if (\\[String\\]::IsNullOrEmpty($err) -eq $true) \\{
                        Write-Host "\\[8/9\\] Installing application content..." 
                        Install-SPApplicationContent -ErrorVariable err

                        if (\\[String\\]::IsNullOrEmpty($err) -eq $true) \\{
                            Write-Host "\\[9/9\\] Basic configuration completed." 

                        \\} else \\{ Write-Error "ERROR: $err" \\}
                    \\} else \\{ Write-Error "ERROR: $err" \\}
                \\} else \\{ Write-Error "ERROR: $err" \\}
            \\} else \\{ Write-Error "ERROR: $err" \\}
        \\} else \\{ Write-Error "ERROR: $err" \\}
    \\} else \\{ Write-Error "ERROR: $err" \\}
\\} else \\{ Write-Error "ERROR: $err" \\}

$exitprompt = Read-Host -Prompt "Configuration complete. Press ENTER to exit"

Dan Holme
Intelliem (

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.