Lubchak Lubchak - 1 year ago 312
PowerShell Question

PowerShell reading property file

I need read properties from config file.
I can do it with

ConvertFrom-StringData(Get-Content test.conf | out-String)

But in this file I have param


And when it's try to parse it I had error:
Unrecognized escape sequence \s.

How can I fix that with script? I can't change file before running script.

Answer Source

Replace the \ with \\:

ConvertFrom-StringData ((Get-Content test.conf -Raw) -replace '\\','\\')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download