Workflow Tools Control Yard

Home / Windows

PowerShell EncodedCommand decoder

Paste a PowerShell command line, or only the Base64 text that follows -EncodedCommand, and read the script it carries. The page runs nothing and sends nothing. Further down: turn a script into an encoded command.

Encode a script

Type or paste a script to get it as an encoded command. This is the form to use when the quotation marks and braces of a script do not survive a command line, a scheduled task or an RMM command step.

Windows PowerShell

powershell.exe -NoProfile -EncodedCommand <Base64>

PowerShell 7

pwsh -NoProfile -EncodedCommand <Base64>

The Base64 text alone

<Base64>

How an encoded command is made

PowerShell wants the script as UTF-16LE text, two bytes for each ordinary character, written out as Base64. Base64 made from UTF-8 or ASCII text looks the same at a glance and does not run; the decoder above says so when it meets one. In PowerShell itself:

$bytes = [System.Text.Encoding]::Unicode.GetBytes($script)
[Convert]::ToBase64String($bytes)

Encoding hides nothing. Anyone can turn the Base64 back into the script, as this page does, and where script block logging is switched on, PowerShell writes the script it ran to the event log.

Options of powershell.exe and pwsh

PowerShell takes a shortened option name as long as it can mean only one option, in upper or lower case, with a slash in place of the dash. The table gives the shortest form of each. It follows the parser of PowerShell 7, whose source is public; Windows PowerShell reads short forms the same way.

OptionShortest formWhat it does
-Version-vWindows PowerShell: start the given version of the engine. PowerShell 7: show its version and stop.
-Help-h, -?Show the help text.
-Login-lPowerShell 7 on Linux and macOS: start as a login shell. Does nothing on Windows.
-NoExit-noeStay open after the commands have run.
-NoProfile-nopDo not load the profile scripts.
-NoLogo-nolDo not show the banner at the start.
-NonInteractive-noniFor runs with nobody at the keyboard: anything that would ask a question ends in an error.
-Interactive-iPowerShell 7: show a prompt. The opposite of -NonInteractive.
-ConfigurationName-configRun in the named session configuration, one of the endpoints registered on the computer.
-Command-cRun what follows as commands. The rest of the line belongs to it.
-WindowStyle-wThe window: Normal, Minimized, Maximized or Hidden.
-File-fRun a script file. What follows the file name is handed to the script.
-OutputFormat-o, -ofHow output is written: Text or XML.
-InputFormat-inp, -ifHow input is read: Text or XML.
-ExecutionPolicy-ex, -epThe execution policy for this session only. The policy set on the computer stays as it is.
-EncodedCommand-e, -ecA command as Base64 text made from UTF-16LE.
-EncodedArguments-encodeda, -eaArguments for a command, as Base64 text made from UTF-16LE.
-SettingsFile-settingsPowerShell 7: use this settings file in place of the one beside the program.
-Sta-staStart with a single-threaded apartment.
-Mta-mtaStart with a multi-threaded apartment.
-WorkingDirectory-wo, -wdPowerShell 7: the folder to start in.

What the decoder points out

The decoder marks the things in this table when it finds them in the command line or in any decoded layer. None of them shows that a command is harmful, and a command with none of them can be. They say where to read closely.

What it looks forWhy it is worth a look
-WindowStyle HiddenRuns without a window on the screen.
-ExecutionPolicy Bypass or UnrestrictedSets the execution policy aside for this one run. Installers and management tools do this too.
Net.WebClient, DownloadString, DownloadFile, Invoke-WebRequest, Invoke-RestMethod, Start-BitsTransferBrings something in from the network.
Invoke-Expression, iexRuns text as code. What runs is whatever that text holds at the moment the command runs.
FromBase64StringDecodes more Base64 inside the script. The decoder unpacks such layers where it can.
GzipStream, DeflateStreamUnpacks compressed data.
Assembly with Load, Add-TypeLoads compiled code into the PowerShell process.
VirtualAlloc, CreateThread, WriteProcessMemory, Marshal with CopyCalls Windows memory functions directly. Administration scripts rarely need to.
AmsiUtils, amsiInitFailedTouches AMSI, the interface that lets security software see scripts.
Set-MpPreference, Add-MpPreferenceChanges Microsoft Defender settings, such as its exclusions.
Register-ScheduledTask, schtasks, New-Service, a Run keySets something up to run again later.
[char] codes, -join, -bxor, many backticksBuilds its text from pieces, which hides what it says from a quick read.
Web addresses and IP addressesNames a place on the network. Shown as text, never as a link.

More Windows tools