Skip to main content
2 of 3
Adding further comment, based on updates to question.
JermDavis
  • 847
  • 6
  • 21

As the message suggests, the error there is because Invoke-WebRequest cannot parse the $url variable that's being passed to it as a parameter. The message is saying that $url includes System.Collections.Hashtable.Sitecore.InstanceName - which suggests to me that there's something wrong with the variable replacement when the $siteName variable is being set up.

$siteName should just be a string from your psd1 file, rather than a collection.

Your question doesn't include the data from your psd1 data file, but the first thing I'd check is that there's not a problem with that which is causing the value of Node.Sitecore.InstanceName to be something other than string.

Just to avoid any possible confusion - I did put some annotation into the example data I gave in my answer to your previous question:

Example with annotation highlighted

The bit highlighted in red there was just annotation - that should not be in the real file...


Edited to add: I've done some more investigating...

As I suspected, I can recreate the exact error message you're seeing if I force the data in $siteName to be a Hashtable rather than a string. I've come up with two ways of doing that in code, rather than in data:

  1. You can explicitly declare it as such by replacing the line that sets it:

    $siteName = $using:Node.Sitecore.InstanceName

    $siteName = @{ InstanceName = "123" }

  2. You can get the $using statement wrong, and access a bit of the config that is a Hashtable:

    $siteName = $using:Node.Sitecore

But clearly you're not doing either of those, based on the code you've posted. And the data you've posted for the .psd1 file looks valid too.

That makes me wonder if the error is in the bits of script that you've not posted? Perhaps in the DSC code that's wrapped around the fragment of script that you posted?

It's a bit of a long shot, but are you sure that you posted the .psd1 data from the file you're actually referencing in your DSC script? If the line where you pass the config accidentally refers to the wrong file, that could cause the structure of the config data to not match the data your script is trying to access?

YourDSCConfigurationName -ConfigurationData "TheWrongConfig.psd1"

Other than that, I'm out of ideas for the moment...

JermDavis
  • 847
  • 6
  • 21