The following Powershell script demonstrates the issue:
$hash = @{\'a\' = 1; \'b\' = 2} Write-Host $hash[\'a\'] # => 1 Write-Host $hash.a
I use this method, since this bug exists in v4 (not in v5)
function render() { [CmdletBinding()] param ( [parameter(ValueFromPipeline = $true)] [string] $str) #buggy #$ExecutionContext.InvokeCommand.ExpandString($str) "@`"`n$str`n`"@" | iex }
Usage for your example:
'$($hash.a)' | render