Skip to content

ConvertTo-UriQueryString

SYNOPSIS

Converts a hashtable of parameters into a URL query string.

SYNTAX

__AllParameterSets

ConvertTo-UriQueryString [-Query] <IDictionary> [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

DESCRIPTION

Takes a hashtable or dictionary of query parameters (keys and values) and constructs a properly encoded query string (e.g. "key1=value1&key2=value2"). By default, all keys and values are URL-encoded per RFC3986 rules to ensure the query string is valid. If a value is an array, multiple entries for the same key are generated.

EXAMPLES

EXAMPLE 1

ConvertTo-UriQueryString -Query @{ foo = 'bar'; search = 'hello world'; ids = 1,2,3 }

Output:

foo=bar&search=hello%20world&ids=1&ids=2&ids=3

Converts the hashtable into a URL-encoded query string. Spaces are replaced with %20.

EXAMPLE 2

ConvertTo-UriQueryString -Query @{ q = 'PowerShell'; verbose = $true }

Output:

q=PowerShell&verbose=True

Converts the query parameters into a valid query string.

PARAMETERS

-Query

The hashtable (or IDictionary) containing parameter names and values. Each key becomes a parameter name. Values can be strings or other types convertible to string. If a value is an array or collection, each element in it will result in a separate instance of that parameter name in the output string.

Type: System.Collections.IDictionary
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: true
  ValueFromPipeline: true
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.Collections.IDictionary

{{ Fill in the Description }}

OUTPUTS

System.String

{{ Fill in the Description }}

NOTES