Functions/Data/ConvertTo-URLEncodingEx.ps1
Function ConvertTo-URLEncodingEx { [CmdletBinding()] Param ( # String to Encode [Parameter(Mandatory=$true,ValueFromPipeline=$true)] [string] $String, # Whether or not to encode periods [Parameter(Mandatory=$false)] [boolean] $EncodeSpace = $True, # Whether or not to encode periods [Parameter(Mandatory=$false)] [boolean] $EncodePeriod = $false ) $Encoded = foreach ($char in ($string -split '')) { if($EncodeSpace -and $char -eq ' '){'%20'} elseif ($EncodePeriod -and $char -eq '.'){'%2E'} else { switch ($char) { '!' {'%21'} '*' {'%2a'} "'" {'%27'} '(' {'%28'} ')' {'%29'} ';' {'%3b'} ':' {'%3a'} '@' {'%40'} '&' {'%26'} '=' {'%3d'} '+' {'%2b'} '$' {'%24'} ',' {'%2c'} '/' {'%2f'} '?' {'%3f'} '%' {'%25'} '#' {'%23'} '[' {'%5b'} ']' {'%5d'} Default {$char} } } } $EncodedString = $Encoded -join '' $EncodedString } |