2

I am trying to install .update file with instructions provided by davis from previous post How to install zip file package from Installation Wizard using Powershell DSC?

I am using another developer's aspx file from https://github.com/adoprog/Sitecore-Deployment-Helpers/blob/master/InstallPackages.aspx

But i am getting below error message while executing through DSC:

PowerShell DSC resource MSFT_ScriptResource  failed to execute Set-TargetResource functionality with error message: Cannot bind parameter 'Uri'. 
Cannot convert value "http://System.Collections.Hashtable.Sitecore.InstanceName\sitecore\admin\InstallPackages.aspx" to type "System.Uri". Error: 
"Invalid URI: The hostname could not be parsed." 
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : HD02TESTCI

Below is the piece of code which I used:

$siteName = $using:Node.Sitecore.InstanceName

$sitecoreFolder = "$($using:Node.WWWRoot)\$($siteName)\sitecore\admin\Packages"   

$module = "$($using:Node.Sitecore.NameOfYourUpdatePackage)"

$query = (Split-Path -Path $module -Leaf)

Write-Verbose "Calling package upload tool for $using:query"

$url = "http://$siteName\sitecore\admin\InstallPackages.aspx"

$result = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 600 -OutFile "C:\$siteName-UpdatePackageResponse-$query.log" -PassThru

Below is the psd1 file content

enter image description here

1 Answer 1

1

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...

4
  • devis I added psd1 file content in the question description.. thanks a lot for helping me Commented Mar 19, 2017 at 16:53
  • Also I am just trying to call the aspx file only.. not using rest of the code Commented Mar 19, 2017 at 17:10
  • When you say "not using the rest of the code" what do you mean? Is this still running in a DSC Script resource?
    – JermDavis
    Commented Mar 19, 2017 at 18:48
  • yes devis it is running in dsc script only as I provided code which i am using in the question above Commented Mar 20, 2017 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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