Skip to content

Instantly share code, notes, and snippets.

@rchaganti
Created June 14, 2019 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rchaganti/33e997f4085cb17cf52e6043138ac031 to your computer and use it in GitHub Desktop.
Save rchaganti/33e997f4085cb17cf52e6043138ac031 to your computer and use it in GitHub Desktop.
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