powershell weirdly encodes ampersands when I try to set the value to an xml attribute

Question:

In my build script, I have a helper powershell function as below:

It works great except that when I try to set the value, it encodes ampersands weirdly. Here is the issue:

Inside my connection string I have &quot value. This should be perfectly valid. However, my above code transforms this into " which is totally unreasonable. Do you have any idea I can solve this problem?

Answer:

Have you try to decode your connection string first? Here is sample:

Source:

powershell weirdly encodes ampersands when I try to set the value to an xml attribute by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply