> For the complete documentation index, see [llms.txt](https://notes.cavementech.com/pentesting-quick-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.cavementech.com/pentesting-quick-reference/active-directory/ad-enumeration/living-off-the-land/powershell-additional-tricks.md).

# Powershell Additional Tricks

### Scanning with Powershell

{% embed url="<https://www.sans.org/blog/pen-test-poster-white-board-powershell-built-in-port-scanner/>" %}
Cheatsheet
{% endembed %}

```
1..1024 | % {echo ((new-object Net.Sockets.TcpClient).Connect("10.0.0.100",$_)) "Port $_ is open!"} 2>$null
```

### Scripts

Scripts with extension “*.ps1”, “*.psm1”, “\*.psd1” etc can be invoked in a specific PowerShell session as follows :thumbsup:

```
Import-Module <Module_Name.ps1>
```

However a PowerShell script can be invoked in a unique way called “dot sourcing a script

```
. .\<Script_Name>.ps1
```
