How to Configure a Commerce Foundation Operation Service Using Windows PowerShell

This topic provides guidance on how to use Microsoft Windows PowerShell script to configure the Commerce Foundation operation service in the application tier.

Prerequisites

To Configure a Commerce Operation Service using Windows PowerShell

The following is a sample Windows PowerShell script that configures the Commerce Foundation operation service in the ChannelConfiguration.config.

In the sample below, the site name (commerceSiteName) is "StoreFrontSite". Modify the script based on your own site information.

$commerceSiteName = "StoreFrontSite"

write-host "Configuring..."

$channelConfigFile=".\ChannelConfiguration.config"

$currentTime = (get-date).tostring("yyyy_mm_dd-hh_mm_s") # year_month_day - hours_mins_seconds   
$backupFileName = "$channelConfigFile.backup_$currentTime"
$xml = [xml](get-content $channelConfigFile)
$xml.Save($backupFileName)

$root = $xml.get_DocumentElement()

$root.Sites.Site.sitename=$commerceSiteName
$root.DefaultChannel.sitename=$commerceSiteName

$registryKey="registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\CommerceServer\9.0 Keys\$commerceSiteName"

$root.Sites.Site.profiles.encryption.publicKey="$registryKey,PublicKey"
$root.Sites.Site.profiles.encryption.privateKey1="$registryKey,PrivateKey"

@($root.ComponentConfigurations.Configuration)[1].CreditCardEncryptionConfiguration.publicKey = "$registryKey,PublicKey"
@($root.ComponentConfigurations.Configuration)[1].CreditCardEncryptionConfiguration.privateKey = "$registryKey,PrivateKey"
        
$xml.Save($channelConfigFile)

write-host "Finish Configuring."