Skip to content

ConvertTo-Base64

SYNOPSIS

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

SYNTAX

__AllParameterSets

ConvertTo-Base64 [-String] <string[]> [[-Encoding] <string>] [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

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

-Encoding

The encoding to use when converting the string to bytes.

Type: System.String
DefaultValue: UTF8
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 1
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-String

The input string or array of strings to be converted to base64 encoding.

Type: System.String[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: true
  ValueFromPipeline: true
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.String[]

{{ Fill in the Description }}

OUTPUTS

System.String

{{ Fill in the Description }}

NOTES

The base64 encoded representation of the input string(s).