Skip to content

Test-Guid

SYNOPSIS

Validates whether a given string is a GUID.

SYNTAX

Test-Guid [-String] <String> [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Checks if the input string matches the standard GUID format. The function returns $true if the string is a valid GUID, otherwise $false.

EXAMPLES

EXAMPLE 1

"550e8400-e29b-41d4-a716-446655440000" | Test-Guid

Returns $true since the provided string is a valid GUID.

EXAMPLE 2

"not-a-guid" | IsGuid

Returns $false because the input is not a valid GUID.

EXAMPLE 3

Test-Guid -String "550e8400-e29b-41d4-a716-446655440000"

Directly checks if the provided string is a valid GUID and returns $true.

PARAMETERS

-String

The string to validate as a GUID.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, 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.Boolean

NOTES

https://psmodule.io/GUID/Functions/Test-Guid/