Skip to content

Get-Uri

SYNOPSIS

Converts a string into a System.Uri, System.UriBuilder, or a normalized URI string.

SYNTAX

AsUri (Default)

Get-Uri [-Uri] <string> [<CommonParameters>]

AsUriBuilder

Get-Uri [-Uri] <string> -AsUriBuilder [<CommonParameters>]

AsString

Get-Uri [-Uri] <string> -AsString [<CommonParameters>]

ALIASES

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

DESCRIPTION

The Get-Uri function processes a string and attempts to convert it into a valid URI. It supports three output formats: a System.Uri object, a System.UriBuilder object, or a normalized absolute URI string. If no scheme is present, "http://" is prefixed to ensure a valid URI. The function enforces mutual exclusivity between the output format parameters.

EXAMPLES

EXAMPLE 1

Get-Uri -Uri 'example.com'

Output:

AbsolutePath   : /
AbsoluteUri    : http://example.com/
LocalPath      : /
Authority      : example.com
HostNameType   : Dns
IsDefaultPort  : True
IsFile         : False
IsLoopback     : False
PathAndQuery   : /
Segments       : {/}
IsUnc          : False
Host           : example.com
Port           : 80
Query          :
Fragment       :
Scheme         : http
OriginalString : http://example.com
DnsSafeHost    : example.com
IdnHost        : example.com
IsAbsoluteUri  : True
UserEscaped    : False
UserInfo       :

Converts 'example.com' into a normalized absolute URI string.

EXAMPLE 2

Get-Uri -Uri 'https://example.com/path' -AsUriBuilder

Output:

Scheme   : https
UserName :
Password :
Host     : example.com
Port     : 443
Path     : /path
Query    :
Fragment :
Uri      : https://example.com/path

Returns a [System.UriBuilder] object for the specified URI.

EXAMPLE 3

'example.com/path' | Get-Uri -AsString

Output:

http://example.com/path

Returns a [string] with the full absolute URI.

PARAMETERS

-AsString

Outputs the URI as a normalized string.

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: AsString
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-AsUriBuilder

Outputs a System.UriBuilder object.

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: AsUriBuilder
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Uri

The string representation of the URI to be processed.

Type: System.String
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.String

{{ Fill in the Description }}

OUTPUTS

System.UriBuilder

{{ Fill in the Description }}

System.String

{{ Fill in the Description }}

System.Uri

{{ Fill in the Description }}

NOTES