PowerShell CmdLets
Commerce Server 11.3 introduced a suite of PowerShell CmdLets that replace the need to use PuP packages, that can import and export data from all subsystems in a uniform way, and can perform all of the capabilities of Commerce Server Manager.
CmdLets require Windows Powershell version 4.0 or later.
The path to the Commerce Server CmdLets is added to the PSModulePath during installation, so the CmdLets are immediately available to you as soon as you open a PowerShell console. You can view all of the available CmdLets in the module by typing:
Get-Command –Module CSPS
To get more information about a specific CmdLet, type Get-Help –detailed New-CSSite
, where New-CSSite
is the name of the CmdLet you want more information about.
The following is an example of a set of command steps that will delete an existing site, create a new site, add the required resources, set up the web services for the legacy tools, secure all of the resources, and import subsystem data.
# Remove existing siteRemove-CSSite
-Name $csSiteName
-DeleteDatabases $true
-DeleteGlobalResources $true;
# Create Site
New-CSSite $csSiteName;
# Create resources
Add-CSCatalogResource $csSiteName;
Add-CSInventoryResource $csSiteName;
Add-CSMarketingResource $csSiteName;
Add-CSOrdersResource $csSiteName;
Add-CSProfilesResource $csSiteName;
# Setup web services
New-CSWebService -Name $csSiteName -Resource Catalog -IISSite $webServiceSiteName;
New-CSWebService -Name $csSiteName -Resource Orders -IISSite $webServiceSiteName;
New-CSWebService -Name $csSiteName -Resource Profiles -IISSite $webServiceSiteName;
New-CSWebService -Name $csSiteName -Resource Marketing -IISSite $webServiceSiteName;
# Secure CS databases
Grant-CSManagementPermissions -Name $csSiteName -Identity $runtimeSiteUser;
Grant-CSCatalogManagementPermissions -Name $csSiteName -Identity $catalogWSUser;
Grant-CSMarketingManagementPermissions -Name $csSiteName -Identity $marketingWSUser;
Grant-CSOrdersManagementPermissions -Name $csSiteName -Identity $ordersWSUser;
Grant-CSProfilesManagementPermissions -Name $csSiteName -Identity $profilesWSUser;
#Import sub-system data
Import-CSCatalog -Name $csSiteName -File $catalogFile;
Import-CSInventory -Name $csSiteName -File $inventoryFile;
Import-CSMarketing -Name $csSiteName -File $marketingFile;
Import-CSOrders -Name $csSiteName -File $ordersFile;
Import-CSOrdersConfig -Name $csSiteName -File $ordersConfigFile;
Import-CSProfiles -Name $csSiteName -File $profilesFile;
If you have a PowerShell window open and are using the Commerce Server CmdLets, and change Commerce Server to point to a different MSCS_Admin database, you will need to restart the PowerShell window for the change to be recognized.