1. Prepare the Microsoft SharePoint Installation Module
Scenario/Problem: You need to have access to extended SharePoint installation commands within PowerShell.
Solution: Download and install the SPModule
from Microsoft.
Before you can install SharePoint from within PowerShell, you need to download and install the SPModule
code from Microsoft. The downloadable file is located at www.microsoft.com/downloads/en/details.aspx?FamilyID=c57556ff-8df0-44fd-aba6-3df01b9f80ce (or search for “SPModule PowerShell”).
Unzip the file and place it into a local folder. Add this folder to the PSModulePath
environment variable. The code is unsigned, so you must allow unsigned scripts to run.
Launch Windows PowerShell by right-clicking
the icon and selecting Run As Administrator. Import the modules
extracted from the zipped SPModule
by using the commands in Listing 1.
Listing 1. Importing the SPModule Components
Import-Module SPModule.misc
Import-Module SPModule.setup
Tip
You must set your execution policy to Unrestricted to successfully import the SPModule.misc
and SPModule.setup
files. You therefore are prompted upon import of some scripts. Entering an R for Run Once installs the scripts properly.
The cmdlets to install and configure SharePoint are now installed and ready for use.
Note
Importing the SPModule.misc
file performs a check for updates. If updates are available, you are notified. Perform any updates before proceeding.
2. Install SharePoint Unattended
Scenario/Problem: You need to install SharePoint from PowerShell.
Solution: Use the Install-SharePoint
cmdlet from the SPModule
.
The first step in unattended installation and configuration is to install SharePoint onto the server. The SPModule
provides the Install-SharePoint
cmdlet to perform the installation. This cmdlet is used in conjunction
with a setup configuration file that contains the installation
parameters.
The SharePoint installation disc includes sample setup configuration files, located in their own folder within Files
, as shown in Figure 1. Listing 2 shows an example of the configuration file contents.
Figure 1. Sample configuration files are contained within the folders shown.
Listing 2. Sample Farm Setup Configuration File
<Configuration>
<Package Id="sts">
<Setting Id="LAUNCHEDFROMSETUPSTS" Value="Yes"/>
</Package>
<Package Id="spswfe">
<Setting Id="SETUPCALLED" Value="1"/>
</Package>
<Logging Type="verbose" Path="%temp%"
Template="SharePoint Server Setup(*).log"/>
<!--<PIDKEY Value="Enter Product Key Here" />-->
<Setting Id="SERVERROLE" Value="APPLICATION"/>
<Setting Id="USINGUIINSTALLMODE" Value="1"/>
<Setting Id="SETUPTYPE" Value="CLEAN_INSTALL"/>
<Setting Id="SETUP_REBOOT" Value="Never"/>
</Configuration>
Copy the config.xml
file that matches your intended installation to a local drive location. Open the file in Notepad and uncomment the PIDKEY
line by removing the <!--
from the front and the -->
from the back. Enter your SharePoint product key in place of Enter Product Key Here
. Save your changes.
You can now use this configuration file with the Import-SharePoint
cmdlet, which has the following syntax:
Install-SharePoint -setupexepath <path to setup.exe on disc>
-configxmlpath <path to the setup config.xml>
Listing 3 shows a sample command-line entry.
Listing 3. Installing SharePoint from the Command Line
Install-SharePoint -setupexepath D:\setup.exe -configxmlpath
c:\config.xml
SharePoint is installed on the server accordingly.
Tip
Install SharePoint on all servers
that will participate in the farm (except for the database server)
before configuring a new farm or joining an existing farm.