Automated SharePoint 2010 Install with PowerShell

In one of my previous posts, I walked through how to provision a SharePoint farm using PowerShell. You can also install SharePoint from a CD using PowerShell as well.  I use this in my lab at home so I don’t have to attend the installs when I am rebuilding my virtual machines.

<Update: Product Keys>

SharePoint Server 2010 Beta (Enterprise Client Access License features) product keys:

Here’s the breakdown:

1. Create an XML file that looks like this. This will do a Full Farm Install (quietly). For other config files, check out e:\Files\SetupFarmSilent\config.xml (e: is the drive with SharePoint on it)

    <Package Id="sts">
        <Setting Id="LAUNCHEDFROMSETUPSTS" Value="Yes"/>

    <Package Id="spswfe">
        <Setting Id="SETUPCALLED" Value="1"/>
        <Setting Id="OFFICESERVERPREMIUM" Value="1" />

    <Logging Type="verbose" Path="%temp%" Template="SharePoint Server Setup(*).log"/>
    <PIDKEY Value="PKXTJ-DCM9D-6MM3V-G86P8-MJ8CY" />
    <Setting Id="SERVERROLE" Value="APPLICATION"/>
    <Setting Id="USINGUIINSTALLMODE" Value="1"/>
    <Setting Id="SETUP_REBOOT" Value="Never" />
    <Setting Id="SETUPTYPE" Value="CLEAN_INSTALL"/>
        <INSTALLLOCATION Value="c:\Program Files\Microsoft SharePoint" />
        <Display Level="Basic" CompletionNotice="Yes" AcceptEULA="Yes" />

2. Next create a PowerShell script, that looks like this (save it to the same folder as the XML file above):

$config = "sharepointInstall_config.xml"
$bits = "e:\"
Write-Progress -Activity "Installing SharePoint Quietly" -Status "Copying config file locally"
Copy-Item $config -Destination $bits
Write-Progress -Activity "Installing SharePoint Quietly" -Status "Installing SharePoint"
cmd.exe /C "$bits\setup.exe /config $config"

3. Now run your script from PowerShell, with the the working directory set to the location of your script files:

PS C:>  cd sharepointScript
PS C:\sharepointScript> .\Install-SharePoint.ps1

4. Wait a few minutes and the install will complete quietly.
5. Proceed to provisioning the farm with PowerShell, here Note:

  Don’t forget to set your execution policy in PowerShell to allow the script to run.  Easiest (but least secure):  Set-ExecutionPolicy Unrestricted