Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Hashtable as resource parameter

$
0
0

Aha, success!

#psm1
param(
    [Microsoft.Management.Infrastructure.CimInstance[]]$AdvancedProperties
)
 
foreach($instance in $AdvancedProperties) {
    Write-Verbose ('Key: {0}, Value: {1}' -f $instance.Key, $instance.Value)
}
 
#schema
[Write, EmbeddedInstance("MSFT_KeyValuePair")] String AdvancedProperties[];

This actually works. Fantastic. It may be that it takes a Hashtable in the DSC configuration, but trying to access Hashtable properties like .Keys apparently makes PowerShell attempt an implicit conversion from KeyValuePair to Hashtable, and this breaks quite spectacularly.

Now to somehow make Get-TargetResource to work…


Viewing all articles
Browse latest Browse all 13067

Trending Articles