Udostępnij za pośrednictwem


Install SharePoint Server 2010 by using Windows PowerShell

 

Applies to: SharePoint Server 2010, SharePoint Foundation 2010

This article discusses how to do a clean installation of Microsoft SharePoint Server 2010 on a stand-alone server or on a server farm by using Windows PowerShell.

Installation process overview:

  • Farm server requirements

  • Prepare SPModule

  • Install Microsoft SharePoint Server 2010 by running Install-SharePoint

  • Configure the farm by using New-SharePointFarm

  • Create a Web Application using Windows PowerShell

  • Deploy services using the SharePoint 2010 Farm Configuration Wizard

  • Create a site collection by using Windows PowerShell

  • Perform additional configuration tasks

  • Add servers to the farm by using Join-SharePointFarm

  • Configure the trace log

You can streamline deployment by using Windows PowerShell to install Microsoft SharePoint Server 2010 in combination with other administrator tools to automate unattended installations and configure the farm.

Farm server requirements

Before you install SharePoint Server 2010, review the following information about permissions, hardware requirements, and software requirements and steps to perform before beginning the process:

Prepare SPModule

The SPModule.zip file is a Windows PowerShell module written by members of the SharePoint Product Group that will install a SharePoint farm.

To use the SPModule.zip file, use the steps below:

  1. Download the SPModule.zip and text file from the following Download Center page (https://go.microsoft.com/fwlink/p/?LinkId=187924).

  2. Extract the files to a folder named SPModule and then add that folder to your environment path. The PSModulePath environment variable is used to store paths to the locations of the modules that are installed on disk. To view paths specified in the PSModulePath variable, from a Windows PowerShell command prompt, type $env:PSModulePath. For more information, see PSModule Environment Variable (https://go.microsoft.com/fwlink/p/?LinkId=187757). After extraction, the SPModule folder should contain two files: SPModule.misc and SPModule.setup.

    Note

    If the SPModule folder is not added to the PSModulePath variable, you must specify a full path to load the SPModule.

  3. Decide on the type of signing to provide.

    Note

    The downloaded files are unsigned. To provide self-signed scripts, see AllSigned: Signing Your PowerShell Scripts (https://go.microsoft.com/fwlink/p/?LinkId=187758).

    By default, Windows PowerShell execution policy is set to Restricted so that no scripts can be run. To change an execution policy, run the Set-ExecutionPolicy cmdlet. For additional information about execution polices, see About_Signing (https://go.microsoft.com/fwlink/p/?LinkId=187759).

  4. Load the SPModule.misc and SPModule.setup files into Windows PowerShell.

    1. Click Start, point to All Programs, and then click Windows PowerShell V2. Once the Windows PowerShell Command Prompt window opens, the first thing we need to do is add the path to the module to your Windows PowerShell module path (presuming you created a folder called "SPModule" on your server):

    2. Right-click Windows PowerShell V2, and then click Run as administrator.

      Note

      If you already have Microsoft SharePoint Server 2010 installed, you could open the SharePoint 2010 Management Shell instead.

    3. Once the Command Prompt window is displayed, we need to import the module into the current Windows PowerShell session and add it to a path by typing the following syntax from a Windows PowerShell command prompt:

      Import-Module SPModule.misc
      
      Import-Module SPModule.setup
      

When you import the SPModule.misc module, you will invoke an update check. In version 1.0, this will check a text file to see if there is a newer version available. If you are notified that there is, you can go and download the newer version. Once the Import-Module commands have completed successfully, you are ready to use SPModule.

Important

The following commands should only be used in the context of the SPModule and the process in this article.

  1. Install-SharePoint: Installs all of the binary files for SharePoint Server 2010. For more information, see Scripted deployment reference (SharePoint Server 2010).

  2. New-SharePointFarm: Creates a SharePoint farm and performs the following related tasks:

    • Configures security

    • Creates a shared service Web application that you can populate with service applications.

    • Creates and configures the Central Administration Web site.

    • Installs all of the product Help files.

    • Installs all farm features.

    For more information, see Scripted deployment reference (SharePoint Server 2010).

  3. Join-SharePointFarm: Adds servers to the farm, and then configures them. For more information, see Scripted deployment reference (SharePoint Server 2010)..

After Windows PowerShell version 2.0 is installed, you can use a new feature of Windows PowerShell called Remoting. By using the remoting feature and a couple lines of Windows PowerShell code, an administrator can remotely install multiple servers in a farm. For information about Remoting and SPModule, see Remote Install with SPModule (https://go.microsoft.com/fwlink/p/?LinkId=187923).

Install Microsoft SharePoint Server 2010 by running Install-SharePoint

After you have determined the required accounts for the installation, you can installSharePoint Server 2010. The product DVD contains examples of configuration (Config.xml) files. These example files are stored under the \Files folder in the root directory of the DVD, in folders that correspond to different scenarios. These example files are described in the following table.

Configuration file

Description

Setup\Config.xml

Stand-alone server installation, using Microsoft SQL Server 2005 Express Edition

SetupFarm\Config.xml

Server farm installation

SetupFarmSilent\Config.xml

Server farm installation in silent mode

SetupFarmUpgrade\Config.xml

In-place upgrade of an existing farm

SetupSilent\Config.xml

Stand-alone server installation, usingSQL Server 2005 Express Edition, in silent mode

SetupSingleUpgrade\Config.xml

In-place upgrade of an existing single-server installation

To run Install-SharePoint with a Config.xml file at a Windows PowerShell command prompt

  1. On the drive on which the SharePoint Server 2010 product DVD is located, change to the root directory to locate the setup.exe file.

  2. Run SPModule.Setup Install-SharePoint with the selected Config.xml file, as follows:

    Install-SharePoint -SetupExePath <path and file name> -ConfigXml <path and file name>

    Note

    You can select one of the example files, or customize your own configuration file.

  3. Press ENTER.

Setup is now finished.

The following example shows the configuration file for setting up a single server in silent mode (SetupSilent).

<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" />
  -->
  <Display Level="none" CompletionNotice="no" />
  <Setting Id="SERVERROLE" Value="APPLICATION" />
  <Setting Id="USINGUIINSTALLMODE" Value="0" />
  <Setting Id="SETUP_REBOOT" Value="Never" />
  <Setting Id="SETUPTYPE" Value="CLEAN_INSTALL" />
  </Configuration>

You can also customize your own configuration file. To control the installation, first edit the Config.xml file in a text editor to include the elements that you want with the appropriate settings for those elements. Next, run Install-SharePoint -SetupExePath -ConfigXML to specify that Setup runs and uses the options that you set in the Config.xml file.

Some typical configuration options include the following:

  • Bypassing the prompt for the product key by providing the key as a value, <PIDKEY Value="Enter PID Key Here" />, in the Config.xml file.

  • Adding a location for a log file, <Logging Type="off" | "standard"(default) | "verbose" Path="path" Template="file name.log"/>, which you can view if command-line installation fails.

Important

Use a text editor, such as Notepad, to edit Config.xml. Do not use a general-purpose XML editor, such as Microsoft Office Word 2007. To validate that your XML file is well-formed, use any supported browser.

Run Install-SharePoint using a PID key

To run Setup in silent mode without using a configuration XML file, type one of the following commands at a Windows PowerShell command prompt:

  • For stand-alone server: Install-SharePoint -SetupExePath "<drive letter>:\SharePoint 2010\Setup\setup.exe" -PIDKey "PVRYW-RRP8H-FG6G2-YGMQW-3V9VX" -ServerRole "SINGLESERVER"

  • For a farm deployment: Install-SharePoint -SetupExePath "<drive letter>:\SharePoint 2010\Setup\setup.exe" -PIDKey "PVRYW-RRP8H-FG6G2-YGMQW-3V9VX"

To run Setup in silent mode using a configuration XML file, type one of the following commands at a Windows PowerShell command prompt:

  • For a stand-alone server: Install-SharePoint -SetupExePath "G:\SharePoint 2010\Setup\setup.exe" -ConfigXML "G:\SharePoint 2010\Setup\Config\singleserver_config.xml"-PIDKey "PVRYW-RRP8H-FG6G2-YGMQW-3V9VX" -ServerRole "SINGLESERVER"

  • For a farm deployment: Install-SharePoint -SetupExePath "G:\SharePoint 2010\Setup\setup.exe" -ConfigXML "G:\SharePoint 2010\Setup\Config\appserver_config.xml"-PIDKey "PVRYW-RRP8H-FG6G2-YGMQW-3V9VX"

Configure the farm by using New-SharePointFarm

You use the New-SharePointFarm command to configure SharePoint Server 2010 after the Install-SharePoint command has finished. The configuration options are different depending on whether you install SharePoint Server 2010 on a stand-alone server or on a server farm.

Configure SharePoint Server 2010 on a stand-alone server

In stand-alone server deployments, you can run New-SharePointFarm. After you have logged on by using the Setup user account that you previously created and configured, you configure SharePoint Server 2010.

To configure SharePoint Server 2010 on a stand-alone server by using New-SharePointFarm

  • At the Windows PowerShell command prompt, type the following command:

    New-SharePointFarm -DatabaseServer <String> -DatabaseAccessAccount <(Get-Credential domain\account)> -FarmName <string>
    

    Where:

    • <String> is name database server. For example, "SQL01"

    • <PSCredential> is the DOMAIN\password of the user account that is performing the installation.

    • <String> is the name of the farm. For example, "Farm1"

The New-SharePointFarm command describes the configuration steps as they occur, and notes the successful completion of configuration. For a stand-alone server installation, this is the final step in a command-line installation.

We strongly recommend that you install and configure SharePoint Server 2010 on all of the farm servers before you create sites.

Warning

Do not run the New-SharePointFarm and Join-SharePointFarm commands simultaneously on multiple computers as contention issues and unpredictable behavior can occur.

Note

If any of these commands fail, look in the post-setup configuration log files. The log files are available at %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\14\Logs, and can be identified by a file name that begins with PowerShell_ConfigurationDiagnostics and the .log file name extension.

Note

The Windows PowerShell cmdlets mentioned in this section must be run from the SharePoint 2010 Management Shell.

To connect to an existing configuration database and join the server to an existing server farm, the Connect–SPConfigurationDatabase cmdlet must be run along with the following Windows PowerShell cmdlets, in this order:

  • Install-SPHelpCollection

  • Initialize-SPResourceSecurity

  • Install-SPService

  • Install-SPFeature -AllExistingFeatures

  • Install-SPApplicationContent

Create a Web Application using Windows PowerShell

Use the New-SPWebApplication cmdlet to create the Web application and a new content database. Use the following example as a guide.

To create a Web application

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

  2. On the Start menu, click All Programs.

  3. Click Microsoft SharePoint 2010 Products.

  4. Click SharePoint 2010 Management Shell.

  5. At the Windows PowerShell command prompt, type the following command:

    New-SPWebApplication -Name <InternetSite> -ApplicationPoolAccount (Get-SPManagedAccount <DOMAIN\UserName>
    

    Where:

    • <InternetSite> is name of the Web application.

    • Domain\UserName is the name of the application pool account.

For more information, see New-SPWebApplication.

Note

We recommend that you use Windows PowerShell when performing command-line administrative tasks. The Stsadm command-line tool has been deprecated, but is included to support compatibility with previous product versions.

Deploy services using the SharePoint 2010 Farm Configuration Wizard

Use the SharePoint Products Configuration Wizard to deploy services on your installation. For information about services and service applications, see Service application and service management (SharePoint Server 2010).

Create a site collection by using Windows PowerShell

You create the top-level site collection by using the New-SPSite cmdlet. The New-SPSite cmdlets creates a site collection at a specific URL with a specified user as a site owner.

To create a site collection

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.

  2. On the Start menu, click All Programs.

  3. Click Microsoft SharePoint 2010 Products.

  4. Click SharePoint 2010 Management Shell.

  5. At the Windows PowerShell command prompt, type the following command:

    New-SPSite <SiteURL> -OwnerAlias <DOMAIN\UserName>
    

    Where:

    • <SiteURL> is the URL of the new site.

    • <DOMAIN\UserName> is the user login name of the site owner.

For more information, see New-SPSite.

Note

We recommend that you use Windows PowerShell when performing command-line administrative tasks. The Stsadm command-line tool has been deprecated, but is included to support compatibility with previous product versions.

If you do not specify the site template to use, site owners can choose the site template when they first browse to the site. You can use the Get-SPWebTemplate cmdlet to display a list of templates.

For a complete list of common templates in SharePoint Server 2010, see Scripted Deployment Reference (SharePoint Server).

If you want to create additional site collections by using Windows PowerShell, you can use the New-SPSite cmdlet.

Note

If you want to create a new content database with the new site, use the New-SPContentDatabase cmdlet or the New-SPSite with the ContentDatabase parameter.

After creating sites, you might want to configure alternate access mappings. Alternate access mappings direct users to the correct URLs during their interaction with SharePoint Server 2010 (while browsing to the home page of a SharePoint site, for example). Alternate access mappings enable SharePoint Server 2010 to map Web requests to the correct Web applications and sites, and they enable SharePoint Server 2010 to serve the correct content back to the user. For more information, see Set-SPAlternateUrl.

Perform additional configuration tasks

After you have installedSharePoint Server 2010, we recommend that you perform the following administrative tasks:

  • Configure outgoing e-mail settings.

  • Configure workflow settings.

  • Configure diagnostic logging settings.

  • Configure antivirus settings.

Add servers to the farm by using Join-SharePointFarm

You must run the Join-SharePointFarm command on all servers you want to add to the farm. To connect to an existing configuration database and join the server to an existing server farm, type the following command on the server (after installing SharePoint Server 2010):

Join-SharePointFarm -DatabaseServer <String> -ConfigurationDatabaseName <String> -Passphrase <SecureString>

Where:

  • <String> is the name of the database server, for example, SQL01.

  • <SecureString> is the password of the user account in the form DOMAIN\password.

Configure the trace log

The trace log can be useful for analyzing problems that might occur. You can use events that are written to the trace log to determine what configuration changes were made in SharePoint Server 2010 before the problem occurred.

By default, SharePoint Server 2010 saves 14 days of events in the trace log files. This means that trace log files that contain events that are older than 14 days are deleted. You can use the Set-SPLogLevel cmdlet to configure all diagnostic logging.

You can use the Diagnostic Logging page in Central Administration to configure the maximum number of trace log files to maintain, and how long (in minutes) to capture events to each log file.

You can also specify where the log files are written or accept the default path by using the Set-SPLogLevel cmdlet.

Trace log files can help you troubleshoot issues related to configuration changes to the Microsoft SharePoint Foundation Search service. Because problems related to configuration changes are not always immediately discovered, we recommend that you save all trace log files that the system creates on any day that you make any configuration changes. Store these log files for some time in a safe location that will not be overwritten. We recommend that you store log files on a hard disk drive partition that is used to store log files only.

For additional information about diagnostic logging, see Configure diagnostic logging (SharePoint Server 2010).