Our requirement was to get the content of the App.config file and App.dll.config file to a PowerShell variable. It was possible to get the content of the App.config file to a PowerShell variable with following command.$appConfig is the App.config file path.
$doc = (Get-Content $appConfigFilePath) -as [Xml]
But when using the same command to read the content of the App.dll.config file it didn't return any value.
Once the App.dll.config is opened using visual studio code, it was possible to see there is a mal- formatted character at the end of App.dll.config file.
As a solution adding alternation to the command to remove mal-formatted character and assign the value to PowerShell variable as follows.
$doc = ((Get-Content -path $appConfigFilePath) -replace "`0", "") -as [xml];
This post explained how to resolve issues in reading mal-formatted xml file content with PowerShell commands.
No comments:
Post a Comment