Skip to content

Test-Base64

SYNOPSIS

Determines whether a given string is a valid base64-encoded string.

SYNTAX

Test-Base64 [-Base64String] <String> [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

This function checks whether the provided string is a valid base64-encoded string. It attempts to decode the input using [Convert]::FromBase64String(). If the decoding succeeds, it returns $true; otherwise, it returns $false.

EXAMPLES

EXAMPLE 1

Test-Base64 -Base64String 'U29tZSBkYXRh'

Output:

True

Returns $true as the string is a valid base64-encoded string.

EXAMPLE 2

'U29tZSBkYXRh' | Test-Base64

Output:

True

Returns $true as the string is a valid base64-encoded string.

PARAMETERS

-Base64String

The base64-encoded string to validate.

Type: String
Parameter Sets: (All)
Aliases:

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

bool

NOTES

Returns $true if the string is a valid base64-encoded string, otherwise $false.

https://psmodule.io/Test/Functions/Test-Base64