ConvertTo-Base64

Converts a value to base-64 encoding.

Syntax

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

Description

For some reason. .NET makes encoding a string a two-step process. This function makes it a one-step process.

You're actually allowed to pass in $null and an empty string. If you do, you'll get $null and an empty string back.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Value String[]

The value to base-64 encoding.

true true (ByValue)
Encoding Encoding

The encoding to use. Default is Unicode.

false false ([Text.Encoding]::Unicode)

EXAMPLE 1

ConvertTo-Base64 -Value 'Encode me, please!'

Encodes Encode me, please! into a base-64 string.

EXAMPLE 2

ConvertTo-Base64 -Value 'Encode me, please!' -Encoding ([Text.Encoding]::ASCII)

Shows how to specify a custom encoding in case your string isn't in Unicode text encoding.

EXAMPLE 3

'Encode me!' | ConvertTo-Base64

Converts Encode me! into a base-64 string.