How do I pass a hashtable as parameter to powershell.exe?
The powershell.exe is started by the IntuneManagementExtension. The behavior can be reproduce by start a powershell.exe from a running powershell console.
OutHash.ps1:
Param(
[hashtable]$hash
)
$hash
Call:
powershell.exe -File .\OutHash.ps1 -hash @{'A'=1}
Output:
Cannot process argument transformation on parameter 'hash'. Cannot convert the "System.Collections.Hashtable" value of type "System.String" to type "System.Collections.Hashtable".
Expected output:
Name Value
---- -----
A 1
Inside the powershell console, this call returns the expected output:
.\OutHash.ps1 -hash @{'A'=1}