Skip to content

Test-URI

SYNOPSIS

Test the validity and response of a given URI.

SYNTAX

Test-URI [[-URI] <Uri>] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

This function sends a HEAD request to the specified URI to test its validity and response. It retrieves details such as the response URI, destination URI, server, and status code. If the URI redirects, the destination URI is decoded and returned.

EXAMPLES

EXAMPLE 1

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

Tests the URI "https://example.com" and returns details about the response.

EXAMPLE 2

"https://example.com" | Test-URI

Pipes the URI "https://example.com" to the function and retrieves response details.

PARAMETERS

-URI

The URI to be tested. Must be a valid and non-empty URI.

Type: Uri
Parameter Sets: (All)
Aliases:

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

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

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

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

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

NOTES