Created
March 4, 2020 14:08
-
-
Save skalahonza/028115a8d0c999044ae58acea0d7120c to your computer and use it in GitHub Desktop.
Converts PowerShell object to JSON. Prevents default PowerShell escaping that breaks the JSON syntax.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Convert to json string - prevent default powershell escaping | |
| $templateOut = $template | ConvertTo-Json -Depth 100 | ForEach-Object { | |
| [Regex]::Replace($_, | |
| "\\u(?<Value>[a-zA-Z0-9]{4})", { | |
| param($m) ([char]([int]::Parse($m.Groups['Value'].Value, | |
| [System.Globalization.NumberStyles]::HexNumber))).ToString() } ) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment