Skip to content

ConvertTo-Base64

SYNOPSIS

Converts a string to its base64 encoded representation.

SYNTAX

ConvertTo-Base64 [-String] <String> [[-Encoding] <String>] [-ProgressAction <ActionPreference>]
 [<CommonParameters>]

DESCRIPTION

This function takes a string as input and converts it to a base64 encoded string using UTF-8 encoding. It accepts input from the pipeline and can process string values directly.

EXAMPLES

EXAMPLE 1

"Hello World" | ConvertTo-Base64

Output:

SGVsbG8gV29ybGQ=

Converts the string "Hello World" to its base64 encoded equivalent.

PARAMETERS

-String

The input string to be converted to base64 encoding.

Type: String
Parameter Sets: (All)
Aliases:

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

-Encoding

The encoding to use when converting the string to bytes.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: UTF8
Accept pipeline input: False
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.String

NOTES

The base64 encoded representation of the input string.

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