PowerShell convert string to base64 value

A laptop is sitting on top of a wooden table.

To convert string value to base64, follow the below steps in the PowerShell command line window:

Encoding to base64 string:

$encoded  = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("test"))write-output $encoded

Output:

dGVzdA==

Decoding base64 string:

$decoded = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($encoded))write-output $decoded

Output:

test

Leave a Comment

Scroll to Top