Guide · 7 min read

Understanding Base64 and PowerShell -EncodedCommand

What Base64 actually does, how to spot it, and the UTF-16LE gotcha that trips people up when decoding PowerShell's -EncodedCommand.

What Base64 Actually Is

Base64 is an encoding scheme, not encryption. It converts arbitrary binary data into a text format made up only of the characters A–Z, a–z, 0–9, + and / (with = used as padding at the end). It exists because many older systems — email (MIME attachments), URLs, JSON, XML — were only designed to safely carry plain text, not arbitrary bytes. Base64 lets binary data travel through those text-only channels without corruption.

Because it's an encoding and not a cipher, Base64 provides zero confidentiality. Anyone can decode it instantly with no key. If you see Base64 used to "hide" something, it's obfuscation at best, not protection.

How to Recognize Base64 at a Glance

A few visual tells help you spot Base64-encoded data in logs, scripts or captured traffic before you even decode it:

  • Only contains A-Z, a-z, 0-9, +, /, and possibly trailing = or == padding.
  • Length is always a multiple of 4 characters (padding with = makes this true).
  • No spaces, and a noticeably even mix of upper/lowercase compared to typical readable text.

Try it yourself with the Base64 Encoder / Decoder — paste any text to see what its encoded form looks like.

Worked Example: Encoding and Decoding Text

The text Hello, IT! encodes to Base64 as follows:

Plain text: Hello, IT! Base64: SGVsbG8sIElUIQ==

Notice the == padding at the end — this pads the encoded output to a multiple of 4 characters, since Base64 processes input in 3-byte groups and encodes each group as 4 characters. Decoding reverses the exact same process. This round-trip is straightforward for plain ASCII text — the complication starts with PowerShell, covered next.

PowerShell's -EncodedCommand: The Gotcha

PowerShell supports running a command passed as Base64 via the -EncodedCommand (or -e) flag, which is common in legitimate automation (avoiding quoting/escaping headaches when passing complex commands through another process) and, just as commonly, in malicious scripts trying to obscure their payload from casual inspection or simple string-matching security tools.

Here's the gotcha that catches people out: PowerShell does not Base64-encode the plain ASCII text of the command. It first converts the command to UTF-16LE (2 bytes per character, little-endian) and then Base64-encodes that. If you take a PowerShell encoded command and run it through a standard Base64 decoder expecting plain ASCII output, you'll get garbled text with what looks like null bytes or odd spacing between every character — because you're seeing the raw UTF-16LE byte pairs decoded as if they were single-byte ASCII.

Worked Example: Decoding a PowerShell Encoded Command

Take the simple command Get-Process. Encoded the way PowerShell expects for -EncodedCommand, it becomes:

Command: Get-Process PowerShell -EncodedCommand form: R wA GB ... (UTF-16LE bytes, then Base64) Actual string: RwBlAHQALQBQAHIAbwBjAGUAcwBzAA==

Decoding that string with a plain Base64-to-ASCII decoder gives you unreadable output. Decoding it correctly requires first Base64-decoding to raw bytes, then interpreting those bytes as UTF-16LE. The Base64 tool includes a dedicated PowerShell mode that handles this UTF-16LE step automatically — paste the encoded string in and it returns the readable command directly.

Why This Matters for Security Work

Encoded PowerShell commands show up constantly in malware analysis, phishing-attachment review and endpoint detection alerts, because -EncodedCommand is a simple way to slip a command past naive keyword filters and make a quick visual read of a script or scheduled task harder. Seeing powershell.exe -enc or -EncodedCommand in a process command line, a scheduled task, or an AV/EDR alert is a strong signal worth decoding immediately rather than dismissing — it does not by itself confirm malicious intent (plenty of legitimate deployment tooling uses it too), but it always deserves a look at what's actually being run.

Tools For This Guide

Frequently Asked Questions

Is Base64 encryption?
No. Base64 is a reversible encoding format with no secret key — anyone can decode it instantly. It should never be relied on to protect sensitive data; it only changes the representation of the data, not its confidentiality.
Why does my Base64 decoder produce garbled text for a PowerShell command?
PowerShell's -EncodedCommand first converts the command to UTF-16LE (2 bytes per character) before Base64-encoding it. A standard decoder assumes single-byte ASCII, so it renders each character with a stray byte between them. Use a decoder with a dedicated PowerShell/UTF-16LE mode instead.
Is seeing an encoded PowerShell command always a sign of malware?
Not by itself. Many legitimate deployment and automation tools use -EncodedCommand to avoid quoting issues when passing commands through another process. It's a signal worth investigating, not a definitive verdict — always decode and read the actual command.
What's the difference between Base64, hex and URL encoding?
All three represent binary or reserved data as safe text, but differently: Base64 packs 3 bytes into 4 characters (most compact of the three), hex represents each byte as two characters (0-9, A-F), and URL encoding (percent-encoding) escapes only the specific characters unsafe in a URL, leaving the rest as plain text.

Decode Base64 and PowerShell Commands Instantly

Includes a dedicated PowerShell -EncodedCommand mode that handles UTF-16LE decoding automatically, entirely in your browser.