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:
PKXTJ-DCM9D-6MM3V-G86P8-MJ8CY
BV7VC-RMR6B-26P6Y-BTQDG-DX2KQ

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)

sharepointInstall_config.xml
----------------------------------------------
<Configuration>
    <Package Id="sts">
        <Setting Id="LAUNCHEDFROMSETUPSTS" Value="Yes"/>
    </Package>

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

    <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" />
</Configuration>

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

Install-SharePoint.ps1
----------------------------------------------------
$config = "sharepointInstall_config.xml"
$bits = "e:\"
cls
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

Comments

  • Anonymous
    December 06, 2009
    Hi Eric - thanks for a great article. It might be worth mentioning that if you do not have the Sharepoint media on a DVD or an ISO image but have a self-extracting exe instead (which is what the default is for MSDN subscribers), the exe can be extracted using something like this: C:en_sharepoint_server_2010_beta_x64_x16-19249.exe /extract:c:ExtractedFiles This extraction will be required in order to use the steps you've outlined. Regards - Martin Kearn