Simple Obfuscation with PowerShell using Base64 Encoding

I recently received a question from someone wanting to know how I encoded a string of text on my blog site. Back in January of 2013, I competed in Jeff Hicks PowerShell Challenge that was held by TrainSignal. One of the questions had an encoded command which you were to decode. I figured out that the -EncodedCommand parameter of PowerShell.exe could not only be used to run commands that are encoded with Base64, that it could also be used to easily decode a string of text that was encoded with Base64.

The help for PowerShell.exe also shows you how to encode a command with Base64:

Encoding something like the domain name for this blog site is easy enough:

While it could be decoded within PowerShell:

Adding quotes around the domain name also allows it to be decoded with PowerShell.exe using the -EncodedCommand parameter without having to encode it with a command such as Write-Output:

The code shown in the previous example specifies the -NoProfile parameter but it’s not required. I’ve added it since calling PowerShell.exe with my profile displays the Packt Publishing free eBook of the day.



  1. Rob

    Quick question – Let’s say I’m examining a potentially malicious script that has been encoded in PowerShell. Is it safe to decode it using -EncodedCommand?

  2. JA

    You can also encode the encoded to make it really obfuscated 😉


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: