Decode Base64-Encoded String on Windows using PowerShell
In this tutorial, I will show how Windows users and developers can encode a given text and decode base64 encoded string using PowerShell commands.
Of course, on web there are some online tools that developers can use to decode encoded text. On the other hand, in case of security and privacy is an issue then it will definitely better to use a built-in tool shipped with your computer's operating system.
Here in this how-to guide I will show sample scripts to encode a sample text and then decode base64 encoded text within Windows PowerShell utility.
Encode Text using Base64 using PowerShell Commands
Assume that you want to encode following string value: "Hi, I hope you like the tips shared in kodyaz.com"
Developers can launch Windows PowerShell and execute below sample script to encode the given desired string.
Note the output of the encoding command, we will use it as input of our following decode command
Decode Base64 Encoded Text on PowerShell
Let's now assume that you are given the base64 encoded string and you want to decode it using PowerShell.
Here is the command you will run on PowerShell tool
And here is the output of the above decoding script that we encoded previously. Just as expected, we are reaching the original string value after decode from base64 encoded text.
Of course, it is possible to parameterize the script by breaking it into functional pieces as follows
And for the reserve operation which is decoding from a base64 encoded string, below revised scipt block can be used on Windows PowerShell tool.
I hope this guide to be useful for especially decoding base64-encoded string values for developers.