Converts a value to base-64 encoding.
ConvertTo-Base64 [-Value] <String[]> [[-Encoding] <Encoding>] [<CommonParameters>]
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.
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) |
ConvertTo-Base64 -Value 'Encode me, please!'
Encodes Encode me, please!
into a base-64 string.
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.
'Encode me!' | ConvertTo-Base64
Converts Encode me!
into a base-64 string.