Description
"Add-Rendering" command fails if "Parameter" parameter is provided in case if run a script using remote session. The same script (I mean "Add-Rendering" part itself) works OK in case if run it in Sitecore PowerShell ISE directly.
Steps to reproduce:
Try to add a rendering to an item using the following remote script in Windows PowerShell:
Import-Module -Name SPE
$session = New-ScriptSession -Username {USER_NAME} -Password {USER_PASSWORD} -ConnectionUri https://{YOUR_SITECORE_HOSTNAME}/
Invoke-RemoteScript -Session $session -ScriptBlock { $rendering = Get-Item -Path "master:/sitecore/layout/Renderings/Sample/Sample Rendering" | New-Rendering; Add-Rendering -Path "{ITEM_PATH}" -Instance $rendering -DataSource "datasource" -Placeholder "main" -FinalLayout -Parameter @{ "sample" = "value" }; }
Stop-ScriptSession -Session $session
Expected result:
The rendering is added successfully.
Actual result:
The error below appears:
Add-Rendering : The Sitecore.Client.ContentDatabase is null.
At line:3 char:1
+ Add-Rendering -Path "master:/sitecore/content/Home/Tests/Presentation ...
+ CategoryInfo : NotSpecified: (:) [Add-Rendering], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Spe.Commands.Presentation.AddRenderingCommand
Note:
It works OK if remove "Parameter" parameter from the "Add-Rendering" command.
Version:
Spe, Version=7.0.0.0 Hotfix SXA-8155-1
Docker Image:
scr.sitecore.com/xmcloud/sitecore-xmcloud-cm:1-ltsc2019