-
Notifications
You must be signed in to change notification settings - Fork 0
/
Invoke-UrlDecode.ps1
35 lines (31 loc) · 1.01 KB
/
Invoke-UrlDecode.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Function Invoke-UrlDecode
{
[cmdletbinding()]
Param
(
[Parameter(ValueFromPipeline)]
[ValidateScript({$_.split('%').count -gt 0})]
[string]$EncodedString
)
Begin
{
$time = [System.Diagnostics.Stopwatch]::StartNew()
$msg = " [ {0:N4} Begin ] {1} initializing..." -f $time.Elapsed.TotalSeconds,$MyInvocation.MyCommand.Name
Write-Verbose $msg
$msg = " [ {0:N4} Begin ] Adding assembly {1}" -f $time.Elapsed.TotalSeconds,'System.Web'
Write-Verbose $msg
add-type -AssemblyName system.web
}
Process
{
$msg = " [ {0:N4} Process ] Decoding {1} characters" -f $time.Elapsed.TotalSeconds,($EncodedString.Split('%').count)
Write-Verbose $msg
$out = [System.Web.HttpUtility]::UrlDecode($EncodedString)
Write-Output $out
}
End
{
$msg = " [ {0:N4} End ] {1} completed." -f $time.Elapsed.TotalSeconds,$MyInvocation.MyCommand.Name
Write-Verbose $msg
}
}