This is just for myself when I forget in the future...
An object returned by the ConvertFrom-JSON
usually returns a PSObject but I need a hash table to properly manipulate and easily pass the hashtable to be consumed by the ARM Template as a parameter.
function ConvertTo-HashtableFromPsCustomObject {
param (
[Parameter(
Position = 0,
Mandatory = $true,
ValueFromPipeline = $true,
ValueFromPipelineByPropertyName = $true
)] [object] $psCustomObject
);
Write-Verbose "[Start]:: ConvertTo-HashtableFromPsCustomObject"
$output = @{};
$psCustomObject | Get-Member -MemberType *Property | % {
$output.($_.name) = $psCustomObject.($_.name);
}
Write-Verbose "[Exit]:: ConvertTo-HashtableFromPsCustomObject"
return $output;
}