Created
June 14, 2019 05:11
-
-
Save rchaganti/33e997f4085cb17cf52e6043138ac031 to your computer and use it in GitHub Desktop.
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
function Get-HttpQueryString | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[Parameter(Mandatory = $true)] | |
[String] | |
$Uri, | |
[Parameter(Mandatory = $true)] | |
[Hashtable] | |
$QueryParameter | |
) | |
# Add System.Web | |
Add-Type -AssemblyName System.Web | |
# Create a http name value collection from an empty string | |
$nvCollection = [System.Web.HttpUtility]::ParseQueryString([String]::Empty) | |
foreach ($key in $QueryParameter.Keys) | |
{ | |
$nvCollection.Add($key, $QueryParameter.$key) | |
} | |
# Build the uri | |
$uriRequest = [System.UriBuilder]$uri | |
$uriRequest.Query = $nvCollection.ToString() | |
return $uriRequest.Uri.OriginalString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment