File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ function New-HttpQueryString
2+ {
3+ # Shamelessly taken from https://powershellmagazine.com/2019/06/14/pstip-a-better-way-to-generate-http-query-strings-in-powershell/
4+ [CmdletBinding ()]
5+ param
6+ (
7+ [Parameter (Mandatory = $true )]
8+ [String ]
9+ $Uri ,
10+
11+ [Parameter (Mandatory = $true )]
12+ [Hashtable ]
13+ $QueryParameter
14+ )
15+ # Add System.Web
16+ Add-Type - AssemblyName System.Web
17+
18+ # Create a http name value collection from an empty string
19+ $nvCollection = [System.Web.HttpUtility ]::ParseQueryString([String ]::Empty)
20+
21+ foreach ($key in $QueryParameter.Keys )
22+ {
23+ $nvCollection.Add ($key , $QueryParameter .$key )
24+ }
25+
26+ # Build the uri
27+ $uriRequest = [System.UriBuilder ]$uri
28+ $uriRequest.Query = $nvCollection.ToString ()
29+
30+ return $uriRequest.Uri.OriginalString
31+ }
You can’t perform that action at this time.
0 commit comments