PowerShell reading property file

Lubchak

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

username=intranet\sysTestAcc

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.

Mathias R. Jessen

Replace the \ with \\:

# The first '\\' is a regex with a '\' escape to create a literal '\'
# The second '\\' is a literal replacement (non-regex) that inserts two '\'
ConvertFrom-StringData ((Get-Content test.conf -Raw) -replace '\\','\\')

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why is my powershell custom property null after reading in this CSV file?

Powershell Script reading file into array

Reading Object's Property Value in Powershell

Reading the file name of downloaded file using PowerShell

How to edit a .property file in powershell

Spring Boot not reading from property file

Property file reading error in spring boot

Reading property file data from a servlet

Reading Java property groups from a file

Oozie property file value not reading from spark

Reading the property file with annotation in spring framework

CMS hippo property reading from .yaml file

Reading value from Spring Property file

Error reading or writing history file in PowerShell on Linux

Reading a text file and finding text using Powershell

Powershell Reading text file word by word

Reading and Parsing a Strucutred Text File with Powershell

Reading list style text file into powershell array

Reading a Large File with PowerShell and delete carriage returns

Powershell - reading, creating and manipulating a csv file

Powershell reading multiple variables from text file

Powershell - Reading CSV File as Individual Lines

How to replace a property in a json file in powershell

Mirth Property File Corrupted on Editing using powershell

Displaying only property name from property file using PowerShell

React JS - Reading environment configurations from external property file

Reading from property file containing utf 8 character

Reading a json file asynchronously, the object property results are always null

Passing a variable to @Value annotation for reading specific property from properties file