0

I'm trying to pick up a passed-in argument to a PowerShell DSC configuration fired by Set-AzureRmVMDscExtension and not having much luck. The idea is to have a xRemoteFile section download a file at a URL in the arguments. The URL is in $certificateSASToken

$dscConfigurationArguments =  @{ 
                            certificateToken = $certificateSASToken 
                           }

Creates the hash table of the arguments, then I'm calling;

Publish-AzureRmVMDscConfiguration -ConfigurationPath ".\DSC\webserver.ps1" -ResourceGroupName "MyResourceGroup" -StorageAccountName "MyStorageAccount" -Force

and then finally;

Set-AzureRmVMDscExtension -Version 2.72 -ResourceGroupName "MyResourceGroup" -VMName "WebServer1" -ArchiveStorageAccountName "MyStorageAccount" -ArchiveBlobName "webserver.ps1.zip" -AutoUpdate:$true -ConfigurationName "WebServer" -ConfigurationArgument $dscConfigurationArguments

In the DSC configuration there's

xRemoteFile TLSCertificateDownload
     {
       Uri = $certificateToken['certificateToken']
       DestinationPath = "C:\webcert.pfx"
       MatchSource = $false
     }

DSC fails because $certificateToken is null. The hash table of config gets all the way through fine because I missed the index on it the first time and it complained that a system object hash table wasn't a URL. Why isn't this getting passed through?

Elomis
  • 313
  • 1
  • 2
  • 13

1 Answers1

1

Your reference in the resource is wrong, it should be:

xRemoteFile TLSCertificateDownload
     {
       Uri = $certificateToken
       DestinationPath = "C:\webcert.pfx"
       MatchSource = $false
     }

Once passed through to the extension your hash table is automatically expanded

Sam Cogan
  • 38,736
  • 6
  • 78
  • 114
  • This wasn't working when I tried it the first time but I've just swapped out what the URL is for a random public text file on Github and it works. The problem with wasn't not indexing the hash table - you don't as you've pointed out - the URL I'm using (with a long list of arguments on the end) has something else wrong. Thanks. – Elomis Feb 13 '18 at 22:21