Share via


How to Configure a Web Application for Two-Tier Deployment and to Activate Features Using Windows PowerShell

This topic provides guidance on how to use Microsoft Windows PowerShell to configure your Microsoft SharePoint 2010 Web application. This procedure is required after you have deployed a customized Web application into a SharePoint 2010 environment on a target server.

Prerequisites

To configure a SharePoint Web application using Windows PowerShell

The following is a sample Windows PowerShell script that sets properties and enables features in a SharePoint 2010 Web application. In this sample, the Windows PowerShell script configures and enables application-level features that are provided with the SharePoint Commerce Services Extensibility Kit.

Note

The sample script below executes code defined in prepackaged sample .wsp files and applies commerce features in SharePoint 2010, including the CommerceServer feature. Upon activation, the CommerceServer feature modifies existing configuration files for the security token service (STS) and the SharePoint Central Admin. These modifications are required in order to establish a path between the STS and the Commerce Foundation using wsHttp binding.

# Add CS Site Name
Write-Host "Adding properties to the web application: " -nonewline
$wa = Get-SPWebApplication $WebAppName

$wa.Properties["IsDistributedFoundation"] = $IsDistributedFoundation
$wa.Properties["CommerceServerSiteName"] = $CommerceServerSiteName
$wa.Properties["FoundationServiceEndPoint"] = $FoundationServiceEndPoint
$wa.Properties["FoundationServiceEndPointFederatedAccess"] = $FoundationServiceEndPointFederatedAccess
$wa.Properties["FoundationServiceEndPointAnonymousAccess"] = $FoundationServiceEndPointAnonymousAccess
$wa.Properties["UserPrincipalName"] = $UserPrincipalName
$wa.Properties["portalsuperuseraccount"] = $SuperUserAccount
$wa.Properties["portalsuperreaderaccount"] = $ManagedAccount

# Only For Development, this basically turn off friendly errors on your site.
$wa.Properties["DevMode"] = "true"

if($ExtendedZoneType -eq "Internet")
{
    $internalSettings = $wa.IisSettings[ [Microsoft.SharePoint.Administration.SPUrlZone]::Default ]
    $publicSettings = $wa.IisSettings[ [Microsoft.SharePoint.Administration.SPUrlZone]::Internet ]
}
else
{
    $internalSettings = $wa.IisSettings[ [Microsoft.SharePoint.Administration.SPUrlZone]::Intranet ]
    $publicSettings = $wa.IisSettings[ [Microsoft.SharePoint.Administration.SPUrlZone]::Default ]
}

$internalSettings.AllowAnonymous = $false
$publicSettings.ClaimsAuthenticationRedirectionUrl = "/_layouts/CommerceServer/LoginRedirectPage.aspx"

$wa.Update()
Write-Host " done" -foregroundcolor darkgreen


Set-SPCustomLayoutsPage -Identity "Login" -RelativePath "/_layouts/custompages/customLogin.aspx" -WebApplication $PublicWebSiteUrl


# Activate WebApplication Level Features
Write-Host "Enabling the CS Features : " -nonewline
Enable-SPFeature -identity "Resources" -URL $wa.Url
Enable-SPFeature -identity "CommerceServerStorefrontSiteResourceDeployment" -URL $wa.Url
Enable-SPFeature -identity "SilverlightWebConfig" -URL $wa.Url
Enable-SPFeature -identity "CommerceServer" -URL $wa.Url
$job = Get-SPTimerJob -identity "job-deploy-commerce-server-activation" -WebApplication $wa
$jobIsDone = $false
do
{
    sleep 1
    if($job.HistoryEntries)
    {
        foreach($entry in $job.HistoryEntries)
        {
            $jobIsDone = $true;
            Write-Host "The commerce server feature activation job finished in " ($entry.EndTime - $entry.StartTime).TotalSeconds " seconds "
        }
    }
}
while(!$jobIsDone)

Write-Host " done" -foregroundcolor darkgreen

Write-Host "Waiting 20 seconds to ensure that the feature activation code is properly executed in all farm nodes:" -nonewline
sleep 20
Write-Host " done" -foregroundcolor darkgreen

Default Web Application Features

The following table shows the features that are set by default in the solution files provided in the SharePoint Commerce Services Extensibility Kit.

Web application-level feature

Description

"Resources"

This feature adds the WebPart Resources files (resx files).

"CommerceServer"

This feature adds the required configuration for a Commerce Server site

"CommerceServerStorefrontSiteResourceDeployment"

This feature adds the Site Template Resources files (resx files).

"SilverlightWebConfig"

This feature adds the Silverlight configurations (required to use Microsoft Commerce Server 2009 R2 Web Business Tools controls).

See Also

Other Resources

Using Windows PowerShell for SharePoint 2010 Commerce Deployment

Walkthrough: Deploying SharePoint 2010 Commerce Solution in a Two-Tier Topology