Converting VBScript's Unescape Function

Definition: Decodes a string encoded with the Escape function.


Suppose someone hands you a string value like this one, a value that has been encoded using the VBScript Escape function (or its equivalent):

Can you use Windows PowerShell to decode this value (that is, turn it back into a regular string value)? You can if you use the .Net Framework’s System.Web.HTTPUtility class and the URLDecode() method. Assuming that the string value is stored in the variable $a these two commands should do the trick:

$a = [web.httputility]::urldecode($a)

When you run the commands and then echo back the value of $a you should get the following:

Return to the VBScript to Windows PowerShell home page