2

I'm setting up some scripts to allow the devs on our team to be able to set up local dev environments easily. I've got all scripts for the install working well except for the last step, where it installs the Sitecore DBs and web root. Here's the script:

#define parameters 
$prefix = "dev" 
$PSScriptRoot = "."
$XConnectCollectionService = "$prefix.xconnect"
$sitecoreSiteName = "$prefix.sc" 
$SolrUrl = "https://solr:8983/solr" 
$SolrRoot = "C:\solr\solr-6.6.2" 
$SolrService = "solr-6.6.2" 
$SqlServer = ".\SQLEXPRESS" 
$SqlAdminUser = "sa" 
$SqlAdminPassword="password"

#install sitecore instance 
$sitecoreParams = @{ 
   Path = "$PSScriptRoot\Packages\sitecore-XP0.json" 
   Package = "$PSScriptRoot\Packages\Sitecore 9.0.1 rev. 171219 (OnPrem)_single.scwdp.zip" 
   LicenseFile = "$PSScriptRoot\Packages\license.xml" 
   SqlDbPrefix = $prefix 
   SqlServer = $SqlServer 
   SqlAdminUser = $SqlAdminUser 
   SqlAdminPassword = $SqlAdminPassword 
   SolrCorePrefix = $prefix 
   SolrUrl = $SolrUrl 
   XConnectCert = $certParams.CertificateName 
   Sitename = $sitecoreSiteName 
   XConnectCollectionService = "https://$XConnectCollectionService" }
Install-SitecoreConfiguration $sitecoreParams

Here's the error I get when I run the script. Happens immediately.

Install-SitecoreConfiguration : Cannot validate argument on parameter 'Path'. The " Test-Path $_ -Type Leaf " validation script for the argument with value "System.Collections.Hashtable" did not return a result of True. Determine why the validation script failed, and then try the command again. At C:\setup\sitecore-dev-install-sc.ps1:18 char:31 + Install-SitecoreConfiguration $sitecoreParams + ~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Install-SitecoreConfiguration], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Install-SitecoreConfiguration

All prerequisites are installed and all other scripts that use the same variables run fine, like the xconnect install, which is very similar. The JSON config file is from the XP Single package download from the Sitecore website. Any ideas what could cause this? Any thoughts on how to debug further?

2 Answers 2

1

Variables in PowerShell are declared and referenced with $ e.g. $sitecoreParams in your script is a hashtable variable.

When calling functions you can use a hashtable to build up all parameters for a function and then pass the single variable to the function instead. This is known as Splatting. Splatting decomposes each key/value in the hashtable and passes as a matching parameter/value to the function

The syntax is slightly different:

# This passes a single hashtable parameter
Install-SitecoreConfiguration $sitecoreParams

#This 'splats' the hashtable passing each key/value as a parameter
Install-SitecoreConfiguration @sitecoreParams

When splatting, the $ for the variable is replaced with @.

In your script you are passing $sitecoreParams as the first parameter to Install-SitecoreConfiguration. The function assumes the first parameter to be Path and so attempts to validate it as a real file path.

The fix is to pass @sitecoreParams so that the hashtable is splatted into the function.

You can find more info on Splatting by running:

Get-Help about_Splatting -ShowWindow
3
  • I thought for sure that would solve it, as all of my other scripts that work are using the @, so this was a typo on my part. But, after changing it to @ in this script, I still get the same error.
    – Scott
    Apr 3, 2018 at 16:36
  • Are you sure it's genuinely the same error? It may still fail if the path is wrong but would give a different reason. The last line definitely needs to have @sitecoreparams
    – Kieranties
    Apr 3, 2018 at 16:41
  • Actually it was a slightly different error. More typos. ugh. Thanks!
    – Scott
    Apr 3, 2018 at 17:19
-1

Please install the below software and try. Restart required after installing the software.

Microsoft ODBC Driver 13 for SQL Server

Microsoft Command Line Utilities 13 for SQL Server

Note: If you are not able to install the Microsoft ODBC Driver 13 for SQL Server due to higher version availability then proceed with installing Microsoft Command Line Utilities 13 for SQL Server

Hope this will helps you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.