Commerce

Installing “Sitecore Commerce Server 8.0” with PowerShell 5 and SQL Server 2014

The Sitecore Commerce Server deployment scripts provided in the dev.sitecore.net download portal do not support PowerShell 5 and SQL server 2014. This blog provides an overview of the issues and presents patches to add support for Windows 10 and SQL Server 2014 installations.

 

Sitecore Commerce Powered by Commerce Server Experience

Commerce Server Logo

Sitecore has been lagging a bit on the commerce front, but not anymore! Have no fear the Sitecore Commerce Server is here! The Commerce Server like a hot potato has been bounced recently from Microsoft to Ascentium, which then ended up in welcoming hands of Sitecore. Recently, I had pleasure dipping my toes into the installation of the new Sitecore commerce solution.

If you are just starting down the same path and reading this article, please keep in mind that Commerce Server was an established platform created without Sitecore in mind. In fact, it’s only a year younger than our favorite Experience Platform. Hopefully keeping that will prevent you from pulling all of your hair out, while trying to install it.

Side Note: I noticed myself using Experience Platform lingo over the Content Management System after reading the Practical Sitecore 8 Configuration and Strategy: A User Guide for Sitecore’s Content and Marketing Capabilities  book. Not that I “drank the koolaid”, but after reading that book the term really started making more sense.

As of the time of this writing, I just got the Commerce Server setup on my local instance which made me feel nostalgic. It really took me back to the good ol’ days of Linux development. Yep. Well, just take a look at this, to install the Sitecore Commerce Server on an existing Sitecore instance manually, you would need to download six different files consisting of installers, script archives, utilities, .zip and .update packages. And then follow a long list of steps to properly install Sitecore Commerce powered by Commerce Server. To make you feel a bit better, I would say that Sitecore put in a good amount of time into writing these scripts, as they automate about an hour of work! Yep, check out a “Quick Install” video for setting up Commerce Server that’s an hour long!

Sitecore promised some major improvements to the Commerce Server integration in the coming 8.2 and 8.3 releases, so I’m holding all of my fingers and toes crossed for these updates, as where it stands now the proper installation alone presents a considerable entry barrier, and this is without getting into the Production install.

 

Issues Installing Sitecore Commerce Powered by Commerce Server

As of now, the biggest “no” in the Sitecore Commerce Server world is Sitecore 8.1. The installation scripts do not account for some things introduced in Sitecore 8.1, for instance, an extracted Sitecore.config file, which results in a whole list of issues. Always keep the Sitecore Commerce Server Compatibility Table handy.

A smooth experience can be reached by following these Commerce Server installation instructions running Sitecore 8 (Update 7 in my case) and using PowerShell 4 with SQL Server 2012. If you have this type of setup, consider yourself lucky! However, if you are up-to-date with technology and run Windows 10 and SQL Server 2014 on your local machine, the waters might get a bit choppy. Fortunately, I was able to come up with fixes for all of them to put you ahead of the game!

 

How to Fix “Error While Invoking getType. Could not find member.” PowerShell 5 Error

If you have Windows 10 installed, your PowerShell would by default be upgraded to version 5. For some unknown reason, this version of PowerShell has a problem recognizing GetType() on an object, even though it shows up as a valid member. Due to this fluke, you may get the following error from the Windows.ps1 script while running Deploy-UnPup.ps1 script from step 6d in the installation instructions.

 

Error while invoking GetType. Could not find member.
At C:\Users\Vasiliy.Fomichev\Downloads\Deploy\Deployment\UtilityScripts\Windows.ps
+ ... s | where { $_.GetType().InvokeMember("Name", 'GetProperty', $null, $ ...

 

To fix this issue, modify line 409 in Deploy\Deployment\UtilityScripts\Windows.ps1 from

 

$member = $members | where { $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null) -ieq $UserName };

to

$member = $members | where { ([ADSI]$_).InvokeGet("Name") -ieq $UserName };

 

Now, simply rerun the script, and it should work just fine.

 

How to Fix “SQL Server Provider for Windows PowerShell is not installed.” Error

If you are using SQL Server 2014 to host the databases, you are not out of the weeds yet. Another error that the Deploy-UnPup.ps1 script will throw is “SQL Server Provider for Windows PowerShell is not installed.” The Known Issues page states “The deployment scripts for installation of Commerce Server 11.2 do not work with SQL 2014. A solution for this issue is being prepared.” Going back to server 2012 is not reasonable. The next likely knee-jerk reaction would be to start researching how to install this provider, however, that is not the real issue. The problem is that the script expects SQL Server 2012 so it references registry paths created by that version of the database engine. After comparing it with the registry keys installed by SQL Server 2014 I was able to modify the script and ran it successfully under that version.

To keep the fix as simple as possible, instead of asking you to modify each reference individually, simply replace the entire Add-SQLPSnapin function in Deploy\Deployment\UtilityScripts\SQL.ps1 with the following:

 

function Add-SQLPSSnapin
{
#
# Add the SQL Server Provider.
#

$ErrorActionPreference = "Stop";

$shellIds = Get-ChildItem HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds;

if(Test-Path -Path "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps120") {
$sqlpsreg = "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps120"
}
elseif(Test-Path -Path "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps120") {
try{
if((Get-PSSnapin -Registered |? { $_.Name -ieq "SqlServerCmdletSnapin120"}).Count -eq 0) {

Write-Host "Registering the SQL Server 2014 Powershell Snapin";

if(Test-Path -Path $env:windir\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe) {
Set-Alias installutil $env:windir\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe;
}
elseif (Test-Path -Path $env:windir\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe) {
Set-Alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe;
}
else {
throw "InstallUtil wasn't found!";
}

if(Test-Path -Path "$env:ProgramFiles\Microsoft SQL Server\120\Tools\PowerShell\Modules\SQLPS\") {
installutil "$env:ProgramFiles\Microsoft SQL Server\120\Tools\PowerShell\Modules\SQLPS\Microsoft.SqlServer.Management.PSProvider.dll";
installutil "$env:ProgramFiles\Microsoft SQL Server\120\Tools\PowerShell\Modules\SQLPS\Microsoft.SqlServer.Management.PSSnapins.dll";
}
elseif(Test-Path -Path "${env:ProgramFiles(x86)}\Microsoft SQL Server\120\Tools\PowerShell\Modules\SQLPS\") {
installutil "${env:ProgramFiles(x86)}\Microsoft SQL Server\120\Tools\PowerShell\Modules\SQLPS\Microsoft.SqlServer.Management.PSProvider.dll";
installutil "${env:ProgramFiles(x86)}\Microsoft SQL Server\120\Tools\PowerShell\Modules\SQLPS\Microsoft.SqlServer.Management.PSSnapins.dll";
}
Add-PSSnapin SQLServer*120;
Write-Host "Sql Server 2014 Powershell Snapin registered successfully.";
}
}catch{}

$sqlpsreg = "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.SqlServer.Management.PowerShell.sqlps120";
}
else {
throw "SQL Server Provider for Windows PowerShell is not installed."
}

$item = Get-ItemProperty $sqlpsreg
$sqlpsPath = [System.IO.Path]::GetDirectoryName($item.Path)

#
# Set mandatory variables for the SQL Server provider
#
Set-Variable -scope Global -name SqlServerMaximumChildItems -Value 0
Set-Variable -scope Global -name SqlServerConnectionTimeout -Value 30
Set-Variable -scope Global -name SqlServerIncludeSystemObjects -Value $false
Set-Variable -scope Global -name SqlServerMaximumTabCompletion -Value 1000

#
# Load the snapins, type data, format data
#
Push-Location
cd $sqlpsPath
if (Get-PSSnapin -Registered | where {$_.name -eq 'SqlServerProviderSnapin100'})
{
if( !(Get-PSSnapin | where {$_.name -eq 'SqlServerProviderSnapin100'}))
{
Add-PSSnapin SqlServerProviderSnapin100;
}
if( !(Get-PSSnapin | where {$_.name -eq 'SqlServerCmdletSnapin100'}))
{
Add-PSSnapin SqlServerCmdletSnapin100;
}
Write-Host "Using the SQL Server 2008 Powershell Snapin.";
Update-TypeData -PrependPath SQLProvider.Types.ps1xml -ErrorAction SilentlyContinue
Update-FormatData -prependpath SQLProvider.Format.ps1xml -ErrorAction SilentlyContinue
}
else #Sql Server 2012 PS Snapin ... should be registered now.  Note, we'll only use it if the earlier version isn't installed.
{
Write-Host "Using the SQL Server 2012 Powershell Snapin.";

if( !(Get-Module | where {$_.name -eq 'sqlps'}))
{
Import-Module 'sqlps' -DisableNameChecking;
}
cd $sqlpsPath;
cd ..\PowerShell\Modules\SQLPS;
Update-TypeData -PrependPath SQLProvider.Types.ps1xml -ErrorAction SilentlyContinue
Update-FormatData -prependpath SQLProvider.Format.ps1xml -ErrorAction SilentlyContinue
}
Pop-Location
}

 

Now , rerun the  Deploy-UnPup.ps1 script and it should run through without a hitch! Voila! We have enabled SQL Server 2014 support!

NOTE: for those of you wondering what Pup and UnPup is – it is a native Commerce Server packaging process. “Pup” stands for Package-Un-Package, which leads to us to a funny term of UnPup, which would literally translate as Up-Package-Un-Pakage…oh boy…

Fortunately, the rest of the installation steps worked without any issues, so I was able to complete them in just a few minutes.  Although, it seemed that the Commerce Server installation is overly complex and disconnected from Sitecore, it is very clear that Sitecore is putting in a lot of effort in automating this process; the PowerShell scripts alone are a great testament to that. Hopefully, this article will save some time and nerves to Sitecore enthusiasts, in the meantime, I will move on with my explorations of the platform and continue keeping my fingers crossed for the coming improvements. Common Sitecore, let’s do it right!

UPDATE: as I was publishing this post, Sitecore Commerce powered by Commerce Server 8.1 got released,  which promises some handy installation improvements, UI enhancements and death of the silly Pup packages. Expect a follow up article soon 🙂


4 comments on “Installing “Sitecore Commerce Server 8.0” with PowerShell 5 and SQL Server 2014
  1. Hao Liu on said:

    keep in mind, the PS deployment scripts mentioned above (not the new PS cmdlets, pup replacement, introduced in 8.1) are not considered as part of the SCpbCS/SCpbMD product. Actually we are not recommending to use them in our later deployment guides (for Reference Stroefront site deployment:http://commercesdn.sitecore.net/SCpbCS81/SCpbCSRefSfGuide/en-us/index.html). The links above which still refers to PS scripts (like Deploy-UnPup.ps1 etc.) are the original documents come with earlier releases.

    Yes I know it’s a bit confusing to keep all different doc versions there.

  2. POLINGTON ALPHONSE on said:

    That fix is also not working for Windows 10

    I have modified the script as follows, It works with no error.

    $member = @($group.psbase.Invoke(“Members”)) | foreach{ if(([ADSI]$_).InvokeGet(“Name”) -ieq $UserName){$UserName}};

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.