scripts

Split-Uri.ps1

SYNOPSIS

Splits a URI into component parts.

SYNTAX

AbsolutePath

Split-Uri.ps1 [-Uri] <Uri> [-AbsolutePath] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Authority

Split-Uri.ps1 [-Uri] <Uri> [-Authority] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Credentials

Split-Uri.ps1 [-Uri] <Uri> [-Credential] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Extension

Split-Uri.ps1 [-Uri] <Uri> [-Extension] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Filename

Split-Uri.ps1 [-Uri] <Uri> [-Filename <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

HostNameType

Split-Uri.ps1 [-Uri] <Uri> [-HostNameType] [-ProgressAction <ActionPreference>] [<CommonParameters>]

IsAbsoluteUri

Split-Uri.ps1 [-Uri] <Uri> [-IsAbsoluteUri] [-ProgressAction <ActionPreference>] [<CommonParameters>]

IsDefaultPort

Split-Uri.ps1 [-Uri] <Uri> [-IsDefaultPort] [-ProgressAction <ActionPreference>] [<CommonParameters>]

IsFile

Split-Uri.ps1 [-Uri] <Uri> [-IsFile] [-ProgressAction <ActionPreference>] [<CommonParameters>]

IsLoopback

Split-Uri.ps1 [-Uri] <Uri> [-IsLoopback] [-ProgressAction <ActionPreference>] [<CommonParameters>]

IsUnc

Split-Uri.ps1 [-Uri] <Uri> [-IsUnc] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Leaf

Split-Uri.ps1 [-Uri] <Uri> [-Leaf] [-ProgressAction <ActionPreference>] [<CommonParameters>]

LeafBase

Split-Uri.ps1 [-Uri] <Uri> [-LeafBase] [-ProgressAction <ActionPreference>] [<CommonParameters>]

ParentPath

Split-Uri.ps1 [-Uri] <Uri> [-ParentPath] [-ProgressAction <ActionPreference>] [<CommonParameters>]

ParentUri

Split-Uri.ps1 [-Uri] <Uri> [-ParentUri] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Hostname

Split-Uri.ps1 [-Uri] <Uri> [-Hostname] [-ProgressAction <ActionPreference>] [<CommonParameters>]

IdnHost

Split-Uri.ps1 [-Uri] <Uri> [-IdnHost] [-ProgressAction <ActionPreference>] [<CommonParameters>]

LocalPath

Split-Uri.ps1 [-Uri] <Uri> [-LocalPath] [-ProgressAction <ActionPreference>] [<CommonParameters>]

PathAndQuery

Split-Uri.ps1 [-Uri] <Uri> [-PathAndQuery] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Port

Split-Uri.ps1 [-Uri] <Uri> [-Port] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Query

Split-Uri.ps1 [-Uri] <Uri> [-Query] [-ProgressAction <ActionPreference>] [<CommonParameters>]

QueryAsDictionary

Split-Uri.ps1 [-Uri] <Uri> [-QueryAsDictionary] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Scheme

Split-Uri.ps1 [-Uri] <Uri> [-Scheme] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Segment

Split-Uri.ps1 [-Uri] <Uri> [-Segment <Int32>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

EXAMPLES

EXAMPLE 1

Split-Uri.ps1 https://webcoder.info/wps-to-psc.html -Leaf

wps-to-psc.html

EXAMPLE 2

Split-Uri.ps1 https://webcoder.info/wps-to-psc.html -IsAbsoluteUri

True

EXAMPLE 3

Split-Uri.ps1 https://webcoder.info/wps-to-psc.html -Authority

webcoder.info

EXAMPLE 4

Split-Uri.ps1 'http://example.net/q?one=something&one=another%20thing&two=second' -QueryAsDictionary

Name Value —- —– one {something, another thing} two second

PARAMETERS

-Uri

Specifies the URI to split.

Type: Uri
Parameter Sets: (All)
Aliases: Url, Href, Src

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

-AbsolutePath

Indicates the absolute path of the URI should be returned.

Type: SwitchParameter
Parameter Sets: AbsolutePath
Aliases:

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

-Authority

Indicates the host/IP and port of the URI (as used to define security contexts) should be returned.

Type: SwitchParameter
Parameter Sets: Authority
Aliases:

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

-Credential

Indicates the credential of the URI should be returned, if a username and/or password was provided.

Type: SwitchParameter
Parameter Sets: Credentials
Aliases:

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

-Extension

Indicates the filename extension of the URI should be returned, if one is available.

Type: SwitchParameter
Parameter Sets: Extension
Aliases:

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

-Filename

Indicates the filename of the new URI should be returned, or the default value if one is not available. Supports format specifiers, {0} for the current date and time and {1} for a GUID.

Type: String
Parameter Sets: Filename
Aliases:

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

-HostNameType

Indicates the type of the hostname of the URI should be returned: Basic, Dns, IPv4, IPv6, Unknown.

Type: SwitchParameter
Parameter Sets: HostNameType
Aliases:

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

-IsAbsoluteUri

Indicates $true should be returned if the URI is absolute, $false otherwise.

Type: SwitchParameter
Parameter Sets: IsAbsoluteUri
Aliases:

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

-IsDefaultPort

Indicates $true should be returned if the URI specifies a default port, $false otherwise.

Type: SwitchParameter
Parameter Sets: IsDefaultPort
Aliases:

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

-IsFile

Indicates $true should be returned if the URI is a file: URI, $false otherwise.

Type: SwitchParameter
Parameter Sets: IsFile
Aliases:

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

-IsLoopback

Indicates $true should be returned if the URI references the localhost, $false otherwise.

Type: SwitchParameter
Parameter Sets: IsLoopback
Aliases:

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

-IsUnc

Indicates $true should be returned if the URI is a UNC path, $false otherwise.

Type: SwitchParameter
Parameter Sets: IsUnc
Aliases:

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

-Leaf

Indicates the final segment of the URI should be returned.

Type: SwitchParameter
Parameter Sets: Leaf
Aliases:

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

-LeafBase

Indicates the final segment of the URI should be returned, without any filename extension.

Type: SwitchParameter
Parameter Sets: LeafBase
Aliases:

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

-ParentPath

Indicates the path of the URI should be returned, without the final segment.

Type: SwitchParameter
Parameter Sets: ParentPath
Aliases:

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

-ParentUri

Indicates the URI should be returned, without the final segment.

Type: SwitchParameter
Parameter Sets: ParentUri
Aliases:

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

-Hostname

Indicates the hostname of the URI should be returned.

Type: SwitchParameter
Parameter Sets: Hostname
Aliases:

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

-IdnHost

Indicates the IDN hostname of the URI should be returned.

Type: SwitchParameter
Parameter Sets: IdnHost
Aliases:

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

-LocalPath

Indicates the OS-localized path of the URI should be returned.

Type: SwitchParameter
Parameter Sets: LocalPath
Aliases:

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

-PathAndQuery

Indicates the absolute path and query of the URI should be returned, separated by ‘?’.

Type: SwitchParameter
Parameter Sets: PathAndQuery
Aliases:

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

-Port

Indicates the port number of the URI should be returned.

Type: SwitchParameter
Parameter Sets: Port
Aliases:

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

-Query

Indicates the querystring of the URI should be returned, including the leading ‘?’.

Type: SwitchParameter
Parameter Sets: Query
Aliases:

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

-QueryAsDictionary

Indicates the querystring of the URI should be returned, as a Hashtable.

Type: SwitchParameter
Parameter Sets: QueryAsDictionary
Aliases:

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

-Scheme

Indicates the scheme of the URI should be returned (http, &c), without the trailing ‘:’.

Type: SwitchParameter
Parameter Sets: Scheme
Aliases:

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

-Segment

Indicates the specified segment index of the URI should be returned, if is available.

Type: Int32
Parameter Sets: Segment
Aliases:

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

-ProgressAction

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

System.Uri containing a URI to extract a part of.

OUTPUTS

System.String for various URI parts that are extracted (usually), or

System.Boolean for various tests of the URI parts, or

System.Int32 to identify the port number if requsted, or

System.UriHostNameType to identify the type of hostname if requested, or

System.Collections.Hashtable containing the querystring name and value pairs if requested, or

System.Management.Automation.PSCredential containing the username and password of the URI if requested.

NOTES