Skip to content

ConvertTo-Base64

SYNOPSIS

Converts a string or array of strings to their base64 encoded representation.

SYNTAX

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

DESCRIPTION

This function takes a string or array of strings as input and converts them to base64 encoded strings using UTF-8 encoding. It accepts input from the pipeline and can process string values directly or as an array.

EXAMPLES

EXAMPLE 1

"Hello World" | ConvertTo-Base64

Output:

SGVsbG8gV29ybGQ=

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

EXAMPLE 2

@("Hello", "World") | ConvertTo-Base64

Output:

SGVsbG8=
V29ybGQ=

Converts each string in the array to its base64 encoded equivalent.

PARAMETERS

-String

The input string or array of strings 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(s).

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