# PowerShell

Adversaries may abuse PowerShell commands and scripts for execution. PowerShell is a powerful interactive command-line interface and scripting environment included in the Windows operating system. Adversaries can use PowerShell to perform a number of actions, including discovery of information and execution of code. Examples included in the Start-Process cmdlet which can be used to run an executable and the Invoke-Command cmdlet which runs command locally or on a remote computer (though administrator permissions are required to use PowerShell to connect to remote systems).

Power Shell may be also used to download and run executables from the internet, which can be executed from disk or in memory without touching disk.

A number of PowerShell-based offensive testing tools are available, including Empire, PowerSploit, PoshC2, and PSAttack.

PowerShell commands/scripts can also be executed without directly invoke the powershell.exe binary through interfaces to PowerShell's underlying System.Management.Automation assembly DLL exposed through the .NET framework and Windows Common Language Interface (CLI).

Some Examples of the PowerShell Command-Line

Whoami, hostname, PWD (Current Directory)

![](/files/-MRhB0wXBz8Y1yx0jG63)

ComputerInfo

![Powershell](/files/-MRhB0wYu4H_7qUpbTo7)

What about grabbing a Remote Shell, well we will use the common IEX Command to achieve that.

![Windows PowerSheII ](/files/-MRhB0wZuUTvhPAl9Bjl)

Shell:

![](/files/-MRhB0w_JGUZ9oerSmEG)

PowerShell is a powerful interface and there are many offensive tools that take advantage of its capabilities do challenge yourself to find them out in the offensive side of things.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dmcxblue.gitbook.io/red-team-notes-2-0/red-team-techniques/execution/t1059-command-and-scripting-interpreter/powershell.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
