Skip to content

Test-Uri

SYNOPSIS

Validates whether a given string is a valid URI.

SYNTAX

__AllParameterSets

Test-Uri [-Uri] <string> [-AllowRelative] [<CommonParameters>]

ALIASES

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

DESCRIPTION

The Test-Uri function checks whether a given string is a valid URI. By default, it enforces absolute URIs. If the -AllowRelative switch is specified, it allows both absolute and relative URIs.

EXAMPLES

EXAMPLE 1

Test-Uri -Uri "https://example.com"

Output:

True

Checks if https://example.com is a valid URI, returning $true.

EXAMPLE 2

Test-Uri -Uri "invalid-uri"

Output:

False

Returns $false for an invalid URI string.

EXAMPLE 3

"https://example.com", "invalid-uri" | Test-Uri

Output:

True
False

Accepts input from the pipeline and validates multiple URIs.

PARAMETERS

-AllowRelative

If specified, allow valid relative URIs.

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

-Uri

Accept one or more URI strings from parameter or pipeline.

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.Boolean]

{{ Fill in the Description }}

System.Boolean

{{ Fill in the Description }}

NOTES

Returns $true if the input string is a valid URI, otherwise returns $false.