Last active
April 25, 2016 21:20
-
-
Save Jaykul/55544f22ab8f49141454e841eeaf923a to your computer and use it in GitHub Desktop.
Breaking PowerShell since ... *muffled sounds*
This file contains 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
<!-- This breaks ConvertTo-JSON for strings --> | |
<Types> | |
<Type> | |
<Name>System.String</Name> | |
<Members> | |
<ScriptProperty> | |
<Name>AsBase64</Name> | |
<GetScriptBlock> | |
[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($this)) | |
</GetScriptBlock> | |
</ScriptProperty> | |
<ScriptProperty> | |
<Name>FromBase64</Name> | |
<GetScriptBlock> | |
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($this)) | |
</GetScriptBlock> | |
</ScriptProperty> | |
</Members> | |
</Type> | |
</Types> |
This file contains 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
<Types> | |
<Type> | |
<!-- This gives me the Base64 functionality, without breaking ConvertTo-JSON --> | |
<Name>System.String</Name> | |
<Members> | |
<ScriptMethod> | |
<Name>ToBase64</Name> | |
<Script> | |
[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($this)) | |
</Script> | |
</ScriptMethod> | |
<ScriptMethod> | |
<Name>FromBase64</Name> | |
<Script> | |
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($this)) | |
</Script> | |
</ScriptMethod> | |
</Members> | |
</Type> | |
</Types |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment