Skip to content

ConvertFrom-UriQueryString

SYNOPSIS

Parses a URL query string into a hashtable of parameters.

SYNTAX

ConvertFrom-UriQueryString [[-Query] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Takes a URI query string (the portion after the '?') and converts it into a hashtable where each key is a parameter name and the corresponding value is the parameter value. If the query string contains the same parameter multiple times, the resulting value will be an array of those values. Percent-encoded characters in the input are decoded back to their normal representation.

EXAMPLES

EXAMPLE 1

ConvertFrom-UriQueryString -Query 'name=John%20Doe&age=30&age=40'

Output:

Name                           Value
----                           -----
name                           John Doe
age                            {30, 40}

Parses the given query string and returns a hashtable where keys are parameter names and values are decoded parameter values.

EXAMPLE 2

'?q=PowerShell%20URI' | ConvertFrom-UriQueryString

Output:

Name                           Value
----                           -----
q                              PowerShell URI

Parses a query string that contains a single parameter and returns the corresponding value.

PARAMETERS

-Query

The query string to parse. This can include the leading '?' or just the key-value pairs. For example, both "?foo=bar&count=10" and "foo=bar&count=10" are acceptable.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

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

INPUTS

OUTPUTS

System.Collections.Hashtable

NOTES

https://psmodule.io/Uri/Functions/ConvertFrom-UriQueryString/