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.
| Part of the command line | What it does |
|---|
Worth a close look
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.
| Option | Shortest form | What it does |
|---|---|---|
-Version | -v | Windows PowerShell: start the given version of the engine. PowerShell 7: show its version and stop. |
-Help | -h, -? | Show the help text. |
-Login | -l | PowerShell 7 on Linux and macOS: start as a login shell. Does nothing on Windows. |
-NoExit | -noe | Stay open after the commands have run. |
-NoProfile | -nop | Do not load the profile scripts. |
-NoLogo | -nol | Do not show the banner at the start. |
-NonInteractive | -noni | For runs with nobody at the keyboard: anything that would ask a question ends in an error. |
-Interactive | -i | PowerShell 7: show a prompt. The opposite of -NonInteractive. |
-ConfigurationName | -config | Run in the named session configuration, one of the endpoints registered on the computer. |
-Command | -c | Run what follows as commands. The rest of the line belongs to it. |
-WindowStyle | -w | The window: Normal, Minimized, Maximized or Hidden. |
-File | -f | Run a script file. What follows the file name is handed to the script. |
-OutputFormat | -o, -of | How output is written: Text or XML. |
-InputFormat | -inp, -if | How input is read: Text or XML. |
-ExecutionPolicy | -ex, -ep | The execution policy for this session only. The policy set on the computer stays as it is. |
-EncodedCommand | -e, -ec | A command as Base64 text made from UTF-16LE. |
-EncodedArguments | -encodeda, -ea | Arguments for a command, as Base64 text made from UTF-16LE. |
-SettingsFile | -settings | PowerShell 7: use this settings file in place of the one beside the program. |
-Sta | -sta | Start with a single-threaded apartment. |
-Mta | -mta | Start with a multi-threaded apartment. |
-WorkingDirectory | -wo, -wd | PowerShell 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 for | Why it is worth a look |
|---|---|
-WindowStyle Hidden | Runs without a window on the screen. |
-ExecutionPolicy Bypass or Unrestricted | Sets the execution policy aside for this one run. Installers and management tools do this too. |
Net.WebClient, DownloadString, DownloadFile, Invoke-WebRequest, Invoke-RestMethod, Start-BitsTransfer | Brings something in from the network. |
Invoke-Expression, iex | Runs text as code. What runs is whatever that text holds at the moment the command runs. |
FromBase64String | Decodes more Base64 inside the script. The decoder unpacks such layers where it can. |
GzipStream, DeflateStream | Unpacks compressed data. |
Assembly with Load, Add-Type | Loads compiled code into the PowerShell process. |
VirtualAlloc, CreateThread, WriteProcessMemory, Marshal with Copy | Calls Windows memory functions directly. Administration scripts rarely need to. |
AmsiUtils, amsiInitFailed | Touches AMSI, the interface that lets security software see scripts. |
Set-MpPreference, Add-MpPreference | Changes Microsoft Defender settings, such as its exclusions. |
Register-ScheduledTask, schtasks, New-Service, a Run key | Sets something up to run again later. |
[char] codes, -join, -bxor, many backticks | Builds its text from pieces, which hides what it says from a quick read. |
| Web addresses and IP addresses | Names a place on the network. Shown as text, never as a link. |
More Windows tools
-
Windows error code lookup
Look up 0x80070005, 0xC000006D, 1603 or any other system error, HRESULT, NTSTATUS or bug check code.
-
Robocopy command builder
Build a robocopy command line, paste one to see what each switch does, and decode its exit codes.
-
Msiexec silent install builder
Build install, uninstall and repair commands and look up MSI exit codes.
-
.reg file value decoder
hex(2), hex(7), hex(b) and dword values of a .reg file as text and numbers, and a value written as .reg lines.
-
Certificate decoder
Read a certificate, a chain or a request: names, dates, thumbprint, template and account SID.
-
Access mask decoder
Read an access mask such as 0x1200A9 or -1610612736 as file, registry or Active Directory rights.
-
icacls explainer and command builder
Read icacls output such as (OI)(CI)(RX) in plain words, or build commands to grant, deny and remove rights.
-
KMS client keys and slmgr commands
Get the KMS client setup key (GVLK) of a Windows or Windows Server edition and the slmgr commands to activate it.
-
File hash checker
Work out the SHA-256, SHA-1, SHA-512 or MD5 hash of a file in your browser and compare it with the publisher's.
-
File type from its first bytes
What a file is by its first bytes, not its name: PDF, ZIP, Office, EXE or DLL with its CPU and bitness.
-
Zone.Identifier reader
The Mark of the Web on a downloaded file: its zone and address, and the commands that show and remove it.
-
Windows and IANA time zone names
Eastern Standard Time to America/New_York or America/Toronto and back, with tzutil, PowerShell and timedatectl.