#1 14 Mar 2014 11:11

New Member
Registered: 14 Mar 2014
Posts: 1

Expand Hash variable while reading file content in PoSH 4.0

I have a xml file where i have defined some HashTable variables, when i read the content at runtime they should be resolved.


It was working in the Powershell 2.0, the snippet is below.
PowerShell 2.0

[xml]$xmlcontent=[xml]($ExecutionContext.InvokeCommand.ExpandString((Get-Content ($xmlFilePath))))

In powershell 4.0, when i execute the same command i am getting the error

Exception calling "ExpandString" with "1" argument(s): "Object reference not set to an instance of an object."



Board footer

Powered by FluxBB