Using Windows PowerShell for SharePoint 2010 Commerce Deployment

Microsoft Commerce Server 2009 R2 leverages the Microsoft Windows PowerShell capabilities provided with Microsoft SharePoint 2010 to perform various deployment activities. Commerce Server 2009 R2 provides sample deployment scripts that you can modify to suit your deployment requirements. The sample scripts are written to deploy either the SharePoint 2010 Solution Storefront or a shell for an ASP.NET site in a two-tier or three-tier configuration. Examples provided in this guide are based on the packaged sample scripts and configurations defined in sample .wsp files. 

This topic provides information about the environment variables used in the Windows PowerShell samples provided as guidance throughout SharePoint 2010 deployment topics in this section. You can use the sample environment file as a starting point to create a new file based on your deployment environment.

Prerequisites

  • You can access the sample code by extracting the .zip archive in the samples folder you selected when you installed the Commerce Server 2009 R2 SDK Samples. In order to use these samples it is assumed that you have extracted them.

  • Information in this section assumes that you have a good working knowledge of Windows PowerShell commands and scripts.

  • You must have the SharePoint 2010 snap-in installed in Windows PowerShell. For more information, refer to your SharePoint 2010 user documentation.

Sample Scripts

Sample deployment scripts are installed during setup by selecting the option to install Developer Kits > Samples. After installation, samples are accessible from the Start menu, under Programs > Commerce Server 2009 R2 > SDK > Samples.

Environment Variables Used in Example Scripts

SharePoint 2010 deployment procedures documented in this section use the prepackaged Windows PowerShell scripts as examples to help you deploy a SharePoint 2010 commerce site. In the sample deployment scripts, the following environment variables are defined in a file called 1-env.ps. 

You can use the sample file (1-env.ps) as a starting point and modify the variables to suit your environment.

# Specify whether you want to extend an intranet zone with an internet zone
# or extend an internet zone with an intranet zone. To do the later, use "Intranet" as the zone type.
# Note that if you extend "Intranet", then you have to modify the default master template page CSDefaultSite.master
# since it has zone based security, modify the line 
#       <commerce:ZoneSecurityTrimmedControl  Permissions="ManageWeb" Zones="Default">            
# to
#        <commerce:ZoneSecurityTrimmedControl  Permissions="ManageWeb" Zones="Intranet">            
# This will instruct the master page to only show the content of that control when it is inside the Intranet zone.
$global:ExtendedZoneType = "Internet"
# Define the application name
$global:WebAppName = "CommerceStoreFrontSite"
$global:WebAppExtendedName = $WebAppName + $ExtendedZoneType
$global:WebAppPoolName = "CommerceStoreFrontSite"

# Define the account used by the Application Pool
$global:ManagedAccount = "contoso.com\username"

# Define the account used by the STS web service
$global:StsAccount = "contoso.com\username"

# Define the super user account
# This user will hold the cache data. It needs access to SharePoint
# SQL, but it cannot be the same as the
# application pool user (defined above). 
# You can create a local account named SPSuperUser and give it the necessary privileges or leave blank
# if the associated performance penality is not a concern.
#$global:SuperUserAccount = ".\SPSuperUser"
$global:SuperUserAccount = ""

# Define the SiteCollection Owner account
$global:SiteOwner = "username\contoso.com"

# Define the Ports of the two SharePoint Zones
$global:WebAppPort = "8000"
$global:WebAppPortExtended = "8001"

# Define the location and names of your solution files.
# The path needs a '\' at the end.  The following example
# shows the pre-prepackaged solution files.
# Location and names of solution files.
# The path needs a '\' at the end
$global:PathToSolutionFiles =  "C:\Program Files (x86)\Microsoft Commerce Server 9.0\SharePointServices\Site\"
$global:SolutionNameWebPart = "MicrosoftCommerceWebParts.wsp"
$global:SolutionNameBusinessMgt = "MicrosoftCommerceBusinessManagement.wsp"
$global:SolutionNameFarmProvisioningLib = "MicrosoftCommerceWebAppProvisioning.wsp"

# The file name of this solution is different depending
#if your are using SP Foundation 2010 or SP Server 2010.
# For SharePoint Server 2010.deployment,
# use MicrosoftCommerceSPServerStorefrontSite.wsp.
# For SharePoint 2010 Foundation deployment,
# use MicrosoftCommerceSPFoundationStorefrontSite.wsp
$global:SolutionNameSiteTemplate = "MicrosoftCommerceSPServerStorefrontSite.wsp"
#$global:SolutionNameSiteTemplate = "MicrosoftCommerceSPFoundationStorefrontSite.wsp"

# Get Computer info  
$Computer = Get-WmiObject -Class Win32_ComputerSystem  
$global:MachineName = $Computer.Name

# Define your deployment configuration.# For a three-tier commerce deployment,
# Set the following attribute to "true"
$global:IsDistributedFoundation = "false"
$global:CommerceServerSiteName = "StoreFrontSite"
# Specify the URL of the Commerce Foundation endpoint.
# For two-tier, replace the <Computer.Name> value with
# the name of the local machine.
# For three-tier, add the URL of the remote Foundation endpoint.
# Example if using non-secure binding:
# http://<app-tier>/<Foundation>/OperationService.svc
# Example if using secure binding:
# https://<app-tier>/<Foundation>/OperationService.svc"
$global:FoundationServiceEndPoint = "http://" + $Computer.Name + ":8000/OperationService.svc"
$global:FoundationServiceEndPointAnonymousAccess = "http://" + $Computer.Name + ":8001/OperationService.svc/anonymous"
$global:FoundationServiceEndPointFederatedAccess = "http://" + $Computer.Name + ":8001/OperationService.svc"
$global:UserPrincipalName = "username@contoso.com"

# The following values are computed based on the values above
if($WebAppPort -eq ("80"))
{
    $global:WebSiteUrl =  "http://" + $MachineName
}
else
{
    $global:WebSiteUrl =  "http://" + $MachineName + ":" + $global:WebAppPort
}

if($WebAppPortExtended -eq ("80"))
{
    $global:WebSiteUrlExtended =  "http://" + $MachineName
}
else
{
    $global:WebSiteUrlExtended =  "http://" + $MachineName + ":" + $global:WebAppPortExtended
}

if($ExtendedZoneType -eq "Internet")
{
$global:PublicWebSiteUrl = $global:WebSiteUrlExtended
}
else
{
$global:PublicWebSiteUrl = $global:WebSiteUrl
}

Note

A managed account is configured using SharePoint 2010 Central Administration. For more information about managed accounts, refer to your SharePoint 2010 documentation.