You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was really difficult to track down. I noticed it when using the xADGroup resource, which works perfectly fine until you use any of the Members* attributes, which are all [string[]]. Then it fails with:
Failed to serialize properties into CimInstance
Which is an error you usually see with composite resources (a known limitation of Invoke-DscResource).
It turns out that the snippet I use (from my own blog 😓 ) to put the parameters into a hashtable results in array parameters reverting to [object[]] even if they were originally more strongly typed.
I traced it back to this line:
$val=Get-Variable-Name $key-ErrorAction Stop |Select-Object-ExpandProperty Value -ErrorAction Stop
Using Select-Object -ExpandProperty Value turns it into [object[]] even though it was originally strongly typed as [string[]].
This was really difficult to track down. I noticed it when using the
xADGroup
resource, which works perfectly fine until you use any of theMembers*
attributes, which are all[string[]]
. Then it fails with:Which is an error you usually see with composite resources (a known limitation of
Invoke-DscResource
).It turns out that the snippet I use (from my own blog 😓 ) to put the parameters into a hashtable results in array parameters reverting to
[object[]]
even if they were originally more strongly typed.I traced it back to this line:
Using
Select-Object -ExpandProperty Value
turns it into[object[]]
even though it was originally strongly typed as[string[]]
.Replacing this with:
Should fix the issue (and it's clearer anyway).
For most code, this is indistinguishable and wouldn't cause a problem.
But of course
Invoke-DscResource
bombs out on it spectacularly, which an unbelievably unhelpful error message.The text was updated successfully, but these errors were encountered: