03 — PowerShell for Cybersecurity
PowerShell is one of the most important scripting and automation technologies for Windows and Microsoft-focused cybersecurity work.
It gives security professionals direct access to:
WINDOWS
USERS
GROUPS
PROCESSES
SERVICES
EVENT LOGS
REGISTRY
FILESYSTEM
NETWORK CONFIGURATION
ACTIVE DIRECTORY
MICROSOFT CLOUD SERVICESThe key difference between PowerShell and many traditional shells is that PowerShell works primarily with:
OBJECTSrather than only plain text.
This makes it extremely powerful for:
SECURITY ADMINISTRATION
INCIDENT RESPONSE
SOC OPERATIONS
WINDOWS HARDENING
ACTIVE DIRECTORY REVIEW
SECURITY AUTOMATION
EVIDENCE COLLECTIONPowerShell Learning Path
Section titled “PowerShell Learning Path”Follow this sequence:
POWERSHELL SHELL ↓CMDLETS ↓OBJECTS ↓PIPELINE ↓VARIABLES ↓CONDITIONS ↓LOOPS ↓FUNCTIONS ↓FILES ↓PROCESSES ↓SERVICES ↓USERS ↓GROUPS ↓EVENT LOGS ↓REGISTRY ↓NETWORKING ↓ACTIVE DIRECTORY ↓SECURITY AUTOMATIONWhy PowerShell Matters in Cybersecurity
Section titled “Why PowerShell Matters in Cybersecurity”Windows remains deeply embedded in enterprise environments.
Cybersecurity professionals regularly need to:
CHECK LOCAL ADMINISTRATORS
REVIEW USER ACCOUNTS
INSPECT SERVICES
ANALYZE EVENT LOGS
REVIEW WINDOWS DEFENDER
CHECK FIREWALL SETTINGS
INSPECT REGISTRY CONFIGURATION
QUERY ACTIVE DIRECTORY
COLLECT INCIDENT EVIDENCEPowerShell makes these tasks repeatable.
PowerShell Mental Model
Section titled “PowerShell Mental Model”The core workflow is:
CMDLET ↓OBJECT ↓PIPELINE ↓FILTER ↓SELECT ↓SORT ↓EXPORTExample:
GET PROCESSES ↓FILTER ↓SELECT INTERESTING FIELDS ↓EXPORT REPORT01 — Start PowerShell
Section titled “01 — Start PowerShell”Check your PowerShell version:
$PSVersionTableYou may be using:
Windows PowerShell 5.1or:
PowerShell 7+Both are useful, but some Windows-specific modules may behave differently.
02 — Understand Cmdlets
Section titled “02 — Understand Cmdlets”PowerShell commands are commonly structured as:
VERB-NOUNExamples:
Get-ProcessGet-ServiceGet-ChildItemGet-LocalUserThis makes command discovery easier.
03 — Discover Commands
Section titled “03 — Discover Commands”Use:
Get-CommandSearch for commands related to services:
Get-Command *Service*Search for event commands:
Get-Command *Event*04 — Get Help
Section titled “04 — Get Help”Use:
Get-Help Get-ProcessDetailed:
Get-Help Get-Process -DetailedExamples:
Get-Help Get-Process -Examples05 — PowerShell Objects
Section titled “05 — PowerShell Objects”Run:
Get-ProcessThe output looks tabular, but each row is an object.
Inspect:
Get-Process |Get-MemberThis shows:
Properties
Methods
Object TypeWhy Objects Matter
Section titled “Why Objects Matter”Instead of manually parsing text, you can directly request properties.
Example:
Get-Process |Select-Object Name, Id, CPU06 — The Pipeline
Section titled “06 — The Pipeline”The pipe:
|passes objects from one cmdlet to another.
Example:
Get-Process |Sort-Object CPU -DescendingThen:
Get-Process |Sort-Object CPU -Descending |Select-Object -First 10Pipeline Mental Model
Section titled “Pipeline Mental Model”GET DATA ↓FILTER ↓SELECT ↓SORT ↓OUTPUT07 — Variables
Section titled “07 — Variables”Create:
$userName = "analyst01"$sourceIP = "10.10.10.25"$failedLogins = 7Print:
$userNameor:
Write-Output $userName08 — Strings
Section titled “08 — Strings”Example:
$message = "Security event detected"Double quotes expand variables:
Write-Output "User: $userName"Single quotes do not:
Write-Output 'User: $userName'09 — Data Types
Section titled “09 — Data Types”Common types include:
String
Integer
Boolean
Array
Hashtable
ObjectCheck:
$userName.GetType()10 — Arrays
Section titled “10 — Arrays”Example:
$hosts = @( "WEB01", "APP01", "DB01")Loop:
foreach ($hostName in $hosts) { Write-Output $hostName}11 — Hashtables
Section titled “11 — Hashtables”Example:
$alert = @{ User = "admin01" SourceIP = "10.10.10.25" Severity = "High"}Access:
$alert["User"]or:
$alert.User12 — Conditions
Section titled “12 — Conditions”Example:
$failedLogins = 12
if ($failedLogins -gt 10) { Write-Output "High-risk authentication activity"}13 — if / elseif / else
Section titled “13 — if / elseif / else”if ($failedLogins -ge 10) { Write-Output "High"}elseif ($failedLogins -ge 5) { Write-Output "Medium"}else { Write-Output "Low"}14 — Comparison Operators
Section titled “14 — Comparison Operators”Common:
-eq Equal
-ne Not equal
-gt Greater than
-lt Less than
-ge Greater or equal
-le Less or equal
-like Wildcard match
-match Regex match15 — Logical Operators
Section titled “15 — Logical Operators”Use:
-and
-or
-notExample:
if (($failedLogins -gt 10) -and (-not $mfaEnabled)) { Write-Output "High-risk condition"}16 — Loops
Section titled “16 — Loops”Example:
foreach ($hostName in $hosts) { Write-Output "Reviewing $hostName"}17 — For Loops
Section titled “17 — For Loops”for ($i = 1; $i -le 5; $i++) { Write-Output "Iteration $i"}18 — While Loops
Section titled “18 — While Loops”$count = 1
while ($count -le 3) { Write-Output "Run $count" $count++}19 — Functions
Section titled “19 — Functions”Example:
function Show-SecurityAlert { param( [string]$Message )
Write-Output "ALERT: $Message"}Call:
Show-SecurityAlert -Message "Multiple failed logins"20 — Function Parameters
Section titled “20 — Function Parameters”Example:
function Get-RiskLevel { param( [int]$Count )
if ($Count -ge 10) { return "High" } elseif ($Count -ge 5) { return "Medium" } else { return "Low" }}21 — Current Security Context
Section titled “21 — Current Security Context”Run:
whoamiThen:
whoami /allReview:
Current User
SID
Groups
Privileges
Integrity Level22 — Identify the Host
Section titled “22 — Identify the Host”Use:
hostnameor:
$env:COMPUTERNAME23 — System Information
Section titled “23 — System Information”Use:
Get-ComputerInfoYou can select specific fields:
Get-ComputerInfo |Select-Object WindowsProductName, WindowsVersion, OsArchitecture24 — Environment Variables
Section titled “24 — Environment Variables”View:
Get-ChildItem Env:Examples:
USERNAME
COMPUTERNAME
USERDOMAIN
USERPROFILE
PATH25 — Filesystem Navigation
Section titled “25 — Filesystem Navigation”Current directory:
Get-LocationList:
Get-ChildItemAlias:
lsChange directory:
Set-Location C:\WindowsAlias:
cd C:\Windows26 — Create a Security Workspace
Section titled “26 — Create a Security Workspace”New-Item ` -ItemType Directory ` -Path C:\Temp\SecurityLab ` -ForceCreate folders:
$folders = @( "Evidence", "Logs", "Reports", "Scripts")
foreach ($folder in $folders) { New-Item ` -ItemType Directory ` -Path "C:\Temp\SecurityLab\$folder" ` -Force | Out-Null}27 — Read Files
Section titled “27 — Read Files”Use:
Get-Content .\security.logFirst lines:
Get-Content .\security.log |Select-Object -First 10Last lines:
Get-Content .\security.log |Select-Object -Last 1028 — Follow a File
Section titled “28 — Follow a File”Use:
Get-Content .\security.log -WaitThis is useful for monitoring lab logs in real time.
29 — Search File Content
Section titled “29 — Search File Content”Use:
Select-String ` -Path .\security.log ` -Pattern "FAILED"30 — Recursive Search
Section titled “30 — Recursive Search”Get-ChildItem .\Logs -File -Recurse |Select-String -Pattern "ERROR"Use only directories you are authorized to inspect.
31 — Write Files
Section titled “31 — Write Files”Use:
"Security analysis started" |Out-File .\report.txtAppend:
"Suspicious event detected" |Out-File .\report.txt -Append32 — CSV
Section titled “32 — CSV”Security products frequently export CSV.
Import:
$events = Import-Csv .\events.csvView:
$events33 — Filter CSV Security Data
Section titled “33 — Filter CSV Security Data”Example:
$events |Where-Object Status -eq "Failed"34 — Export CSV
Section titled “34 — Export CSV”$events |Export-Csv .\reports\events.csv -NoTypeInformation35 — JSON
Section titled “35 — JSON”Convert PowerShell objects to JSON:
$alert = @{ User = "admin01" Severity = "High"}
$alert |ConvertTo-Json36 — Read JSON
Section titled “36 — Read JSON”$data = Get-Content .\alert.json -Raw |ConvertFrom-JsonAccess:
$data.User37 — Filtering Objects
Section titled “37 — Filtering Objects”Use:
Where-ObjectExample:
Get-Service |Where-Object Status -eq "Running"38 — Select Properties
Section titled “38 — Select Properties”Use:
Select-ObjectExample:
Get-Service |Select-Object Name, Status39 — Sort Results
Section titled “39 — Sort Results”Get-Process |Sort-Object CPU -Descending40 — Group Results
Section titled “40 — Group Results”Use:
Group-ObjectExample:
Get-Service |Group-Object Status41 — Measure Results
Section titled “41 — Measure Results”Use:
Measure-ObjectExample:
Get-Process |Measure-Object42 — Processes
Section titled “42 — Processes”List:
Get-ProcessUseful fields:
Get-Process |Select-Object Name, Id, CPU, PathSome process paths may require additional privileges.
43 — Find a Process
Section titled “43 — Find a Process”Get-Process -Name powershellor:
Get-Process |Where-Object Name -like "*chrome*"44 — Services
Section titled “44 — Services”List:
Get-ServiceRunning services:
Get-Service |Where-Object Status -eq "Running"45 — Detailed Service Configuration
Section titled “45 — Detailed Service Configuration”Use:
Get-CimInstance Win32_Service |Select-Object Name, StartName, State, PathNameThis is extremely useful for security assessment.
46 — Service Security Questions
Section titled “46 — Service Security Questions”For each important service ask:
What Does It Do?
Which Account Runs It?
Where Is Its Executable?
Is It Expected?
Is It Privileged?
Who Can Modify Its Files?47 — Scheduled Tasks
Section titled “47 — Scheduled Tasks”Use:
Get-ScheduledTaskSelect:
Get-ScheduledTask |Select-Object TaskName, TaskPath, State48 — Local Users
Section titled “48 — Local Users”Use:
Get-LocalUserReview:
Enabled
Last Logon
Description
Account Expiration49 — Local Groups
Section titled “49 — Local Groups”Use:
Get-LocalGroup50 — Review Administrators
Section titled “50 — Review Administrators”Use:
Get-LocalGroupMember AdministratorsThis is one of the most useful Windows security checks.
51 — Group Membership Security
Section titled “51 — Group Membership Security”Ask:
WHO IS LOCAL ADMIN?
WHY?
IS ACCESS STILL REQUIRED?
IS IT A USER OR GROUP?
IS THE ASSIGNMENT TOO BROAD?52 — Filesystem Permissions
Section titled “52 — Filesystem Permissions”Use:
Get-Acl C:\Path\To\ResourceReview:
Owner
Access
Identity
Rights
Inheritance53 — Permission Security Model
Section titled “53 — Permission Security Model”Think:
IDENTITY ↓ACL ↓RESOURCE ↓READ / WRITE / MODIFY / FULL CONTROL54 — Registry Basics
Section titled “54 — Registry Basics”PowerShell exposes the Registry as a provider.
Examples:
Get-ChildItem HKLM:\Get-ChildItem HKCU:\55 — Read Registry Values
Section titled “55 — Read Registry Values”Example:
Get-ItemProperty ` "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion"56 — Registry Security
Section titled “56 — Registry Security”Inspect ACLs:
Get-Acl ` "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion"The registry can contain security-relevant configuration.
57 — Network Configuration
Section titled “57 — Network Configuration”Use:
Get-NetIPConfigurationor:
Get-NetIPAddress58 — Routes
Section titled “58 — Routes”Use:
Get-NetRoute59 — DNS Configuration
Section titled “59 — DNS Configuration”Use:
Get-DnsClientServerAddress60 — Network Connections
Section titled “60 — Network Connections”Use:
Get-NetTCPConnectionFilter listening:
Get-NetTCPConnection |Where-Object State -eq "Listen"61 — Map Ports to Processes
Section titled “61 — Map Ports to Processes”Example:
Get-NetTCPConnection -State Listen |Select-Object LocalAddress, LocalPort, OwningProcessThen:
Get-Process -Id <PID>62 — Test Connectivity
Section titled “62 — Test Connectivity”For an authorized system:
Test-NetConnection ` -ComputerName <LAB_HOST> ` -Port 443Use only approved destinations.
63 — DNS Lookup
Section titled “63 — DNS Lookup”Use:
Resolve-DnsName example.comor authorized internal lab names.
64 — Event Logs
Section titled “64 — Event Logs”Windows event logs are extremely important for security operations.
Common logs include:
Security
System
Application
PowerShell
Microsoft Defender65 — List Event Logs
Section titled “65 — List Event Logs”Use:
Get-WinEvent -ListLog *66 — Read Security Events
Section titled “66 — Read Security Events”Example:
Get-WinEvent ` -LogName Security ` -MaxEvents 20Access to Security logs may require appropriate privileges.
67 — Filter by Event ID
Section titled “67 — Filter by Event ID”Example:
Get-WinEvent ` -FilterHashtable @{ LogName = "Security" Id = 4625 } ` -MaxEvents 20Event ID:
4625typically represents failed logon events.
68 — Useful Security Events
Section titled “68 — Useful Security Events”Examples:
4624Successful Logon
4625Failed Logon
4672Special Privileges Assigned
4688Process Creation
4720User Created
4726User Deleted
4732Member Added to Local Group
4740Account Locked Out
4698Scheduled Task Created
4702Scheduled Task UpdatedExact logging depends on system configuration.
69 — Failed Login Investigation
Section titled “69 — Failed Login Investigation”Example:
$events = Get-WinEvent ` -FilterHashtable @{ LogName = "Security" Id = 4625 } ` -MaxEvents 100Count:
$events.Count70 — Event Object Inspection
Section titled “70 — Event Object Inspection”Inspect one:
$events[0] |Format-List *This helps you understand available fields before building automation.
71 — Export Event Information
Section titled “71 — Export Event Information”Example:
$events |Select-Object TimeCreated, Id, MachineName |Export-Csv ` .\Reports\failed-logins.csv ` -NoTypeInformation72 — Event Analysis Workflow
Section titled “72 — Event Analysis Workflow”EVENT LOG ↓GET-WINEVENT ↓FILTER ↓SELECT ↓GROUP ↓EXPORT73 — PowerShell Operational Logs
Section titled “73 — PowerShell Operational Logs”Review PowerShell logging where enabled.
Examples may include:
Microsoft-Windows-PowerShell/OperationalList events:
Get-WinEvent ` -LogName "Microsoft-Windows-PowerShell/Operational" ` -MaxEvents 2074 — Windows Defender
Section titled “74 — Windows Defender”Where available:
Get-MpComputerStatusReview fields such as:
Antivirus Enabled
Real-Time Protection
Signature Status75 — Defender Security Rule
Section titled “75 — Defender Security Rule”During normal security assessment:
DO NOT DISABLE DEFENDERsimply to make testing easier.
Assess the security posture without unnecessarily weakening controls.
76 — Windows Firewall
Section titled “76 — Windows Firewall”Use:
Get-NetFirewallProfileReview:
Domain
Private
Public77 — Firewall Rules
Section titled “77 — Firewall Rules”Use:
Get-NetFirewallRuleFor focused reviews:
Get-NetFirewallRule |Where-Object Enabled -eq "True"78 — Audit Policy
Section titled “78 — Audit Policy”Use:
auditpol /get /category:*Review areas such as:
Logon
Account Management
Privilege Use
Process Creation
Policy Change79 — Windows Update Context
Section titled “79 — Windows Update Context”Security review may include patch posture.
Use appropriate enterprise tooling where available rather than relying only on ad hoc local commands.
Document:
Patch Governance
Update Service
Last Maintenance
Critical Missing Updates80 — Active Directory Context
Section titled “80 — Active Directory Context”If the host is domain joined:
$env:USERDOMAIN$env:USERDNSDOMAIN81 — Discover Domain Controller
Section titled “81 — Discover Domain Controller”Use:
nltest /dsgetdc:<DOMAIN>where authorized.
82 — Domain Users
Section titled “82 — Domain Users”Basic:
net user /domainIf the AD module is available:
Get-ADUser -Filter *83 — Domain Groups
Section titled “83 — Domain Groups”Basic:
net group /domainWith AD module:
Get-ADGroup -Filter *84 — Domain Admins
Section titled “84 — Domain Admins”Use:
net group "Domain Admins" /domainThis is useful for identifying highly privileged membership.
85 — Active Directory Computers
Section titled “85 — Active Directory Computers”If available:
Get-ADComputer -Filter * |Select-Object Name, OperatingSystem86 — Service Accounts
Section titled “86 — Service Accounts”If AD module is available:
Get-ADUser ` -Filter {ServicePrincipalName -like "*"} ` -Properties ServicePrincipalNameUse this for authorized inventory and governance review.
87 — AD Security Mindset
Section titled “87 — AD Security Mindset”Think:
USER ↓GROUP ↓PERMISSION ↓COMPUTER ↓APPLICATION ↓PRIVILEGEPowerShell is useful for mapping these relationships.
88 — Group Policy Context
Section titled “88 — Group Policy Context”Use:
gpresult /rThis helps identify policies applied to the current user and computer.
89 — Registry and Policy Review
Section titled “89 — Registry and Policy Review”PowerShell allows you to automate configuration checks against approved security baselines.
Example categories:
UAC
Audit Policy
Firewall
Password Policy
Defender
Remote Administration90 — PowerShell Remoting Concept
Section titled “90 — PowerShell Remoting Concept”PowerShell supports remote administration.
Conceptually:
ADMIN ↓POWERSHELL REMOTING ↓REMOTE WINDOWS HOSTUse remoting only with explicit authorization and approved credentials.
91 — Security Automation Principle
Section titled “91 — Security Automation Principle”A good automation script should:
COLLECT
VALIDATE
FILTER
NORMALIZE
REPORTIt should not make high-impact changes automatically unless the workflow explicitly requires and approves them.
92 — Build a Windows Security Inventory
Section titled “92 — Build a Windows Security Inventory”Collect:
Hostname
OS
Current User
Local Administrators
Running Services
Listening Ports
Firewall State
Defender State93 — Example Inventory Structure
Section titled “93 — Example Inventory Structure”$inventory = [PSCustomObject]@{ ComputerName = $env:COMPUTERNAME User = $env:USERNAME Domain = $env:USERDOMAIN}Print:
$inventory94 — PSCustomObject
Section titled “94 — PSCustomObject”This is one of the most useful PowerShell features for reporting.
Example:
$result = [PSCustomObject]@{ Hostname = $env:COMPUTERNAME Finding = "Firewall Enabled" Status = "Pass"}95 — Export Structured Results
Section titled “95 — Export Structured Results”$result |Export-Csv ` .\Reports\security-check.csv ` -NoTypeInformation96 — Build Multiple Results
Section titled “96 — Build Multiple Results”$results = @()
$results += [PSCustomObject]@{ Check = "Firewall" Status = "Pass"}
$results += [PSCustomObject]@{ Check = "Defender" Status = "Review"}97 — Filter Results
Section titled “97 — Filter Results”$results |Where-Object Status -eq "Review"98 — Generate HTML Reports
Section titled “98 — Generate HTML Reports”PowerShell can convert objects:
$results |ConvertTo-Html |Out-File .\Reports\report.htmlThis is useful for simple internal reports.
99 — Error Handling
Section titled “99 — Error Handling”Use:
try { Get-Content .\security.log -ErrorAction Stop}catch { Write-Output "Unable to read security.log"}100 — Why -ErrorAction Stop Matters
Section titled “100 — Why -ErrorAction Stop Matters”Some PowerShell errors are non-terminating.
Using:
-ErrorAction Stopcan allow try/catch to handle them consistently.
101 — finally
Section titled “101 — finally”Example:
try { Write-Output "Processing"}catch { Write-Output "Error"}finally { Write-Output "Cleanup"}Useful when cleanup must always happen.
102 — Script Logging
Section titled “102 — Script Logging”Example:
function Write-SecurityLog { param( [string]$Message )
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
"$timestamp $Message" | Out-File ` .\Reports\script.log ` -Append}103 — Do Not Log Secrets
Section titled “103 — Do Not Log Secrets”Avoid writing:
Passwords
Access Tokens
Private Keys
Complete Session Tokensinto script logs.
104 — Script Parameters
Section titled “104 — Script Parameters”Example:
param( [string]$ComputerName)Run:
.\security-check.ps1 ` -ComputerName APP01105 — Validate Parameters
Section titled “105 — Validate Parameters”Example:
param( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string]$LogPath)PowerShell supports many validation attributes.
106 — Validate Sets
Section titled “106 — Validate Sets”Example:
param( [ValidateSet( "Low", "Medium", "High", "Critical" )] [string]$Severity)107 — Script Structure
Section titled “107 — Script Structure”A good PowerShell script may contain:
PARAMETERS
CONFIGURATION
FUNCTIONS
COLLECTION
ANALYSIS
OUTPUT
ERROR HANDLING
CLEANUP108 — Secure Coding Considerations
Section titled “108 — Secure Coding Considerations”Avoid:
Hard-Coded Secrets
Unvalidated Input
Excessive Privilege
Unsafe Dynamic Command Construction
Unnecessary Remote Execution
Sensitive Logging109 — Avoid Dynamic Code Execution
Section titled “109 — Avoid Dynamic Code Execution”Treat features such as dynamically evaluating command strings with caution.
Prefer:
NATIVE CMDLETS
PARAMETERS
OBJECT PIPELINESinstead of interpreting untrusted input as executable code.
110 — Least Privilege
Section titled “110 — Least Privilege”Do not automatically launch PowerShell as Administrator.
Ask:
WHICH COMMANDACTUALLY REQUIRESELEVATED ACCESS?Run standard-user workflows as a standard user whenever possible.
111 — Execution Policy
Section titled “111 — Execution Policy”View:
Get-ExecutionPolicyExecution policy is a script-execution safety feature, not a complete security boundary.
Do not weaken policy merely to run unknown code.
112 — Script Signing Concept
Section titled “112 — Script Signing Concept”In managed environments, scripts may be signed to provide:
AUTHOR VERIFICATION
INTEGRITY
TRUST MANAGEMENTThis can support enterprise automation governance.
113 — PowerShell Transcription
Section titled “113 — PowerShell Transcription”PowerShell can support session transcription in managed environments.
This can help organizations capture:
ADMINISTRATIVE ACTIVITY
SCRIPT EXECUTION
INVESTIGATION CONTEXTaccording to organizational policy.
114 — Logging and Monitoring
Section titled “114 — Logging and Monitoring”Organizations should consider:
PowerShell Operational Logs
Script Block Logging
Module Logging
Process Creation
EDR Telemetrywhere appropriate.
115 — Project 01: Local Administrator Audit
Section titled “115 — Project 01: Local Administrator Audit”Create a script that:
GETS HOSTNAME
COLLECTS LOCAL ADMINISTRATORS
IDENTIFIES USERS / GROUPS
EXPORTS CSVExample base command:
Get-LocalGroupMember Administrators116 — Project 02: Windows Service Inventory
Section titled “116 — Project 02: Windows Service Inventory”Collect:
Service Name
State
Startup Type
Service Identity
Executable PathUse:
Get-CimInstance Win32_Service117 — Project 03: Failed Login Analyzer
Section titled “117 — Project 03: Failed Login Analyzer”Build:
SECURITY LOG ↓EVENT 4625 ↓EXTRACT EVENTS ↓COUNT ↓GROUP ↓REPORT118 — Project 04: Defender Status Report
Section titled “118 — Project 04: Defender Status Report”Collect:
Host
Antivirus State
Real-Time Protection
Signature State
Timestampusing approved Defender cmdlets.
119 — Project 05: Windows Firewall Audit
Section titled “119 — Project 05: Windows Firewall Audit”Collect:
Profile
Enabled
Default Inbound
Default OutboundThen export a report.
120 — Project 06: Windows Security Inventory
Section titled “120 — Project 06: Windows Security Inventory”Combine:
SYSTEM INFO
LOCAL ADMINS
SERVICES
PORTS
FIREWALL
DEFENDER
AUDIT POLICYinto a single security inventory.
121 — Project 07: Event Log Exporter
Section titled “121 — Project 07: Event Log Exporter”Allow the analyst to specify:
Log Name
Event ID
Time Range
Maximum Events
Output FileThen export structured evidence.
122 — Project 08: Active Directory Inventory
Section titled “122 — Project 08: Active Directory Inventory”In an authorized domain lab, collect:
Users
Groups
Computers
Privileged Groups
Service Accountsand export sanitized reports.
123 — Project 09: File Hash Collection
Section titled “123 — Project 09: File Hash Collection”Use:
Get-FileHashExample:
Get-FileHash .\sample.txt -Algorithm SHA256124 — Evidence Hashing
Section titled “124 — Evidence Hashing”For collected evidence:
Get-FileHash ` .\Evidence\security.evtx ` -Algorithm SHA256Record the hash alongside evidence metadata.
125 — Project 10: Security Configuration Checker
Section titled “125 — Project 10: Security Configuration Checker”Create checks for:
Firewall
Defender
Local Administrators
Audit Policy
Selected ServicesReturn:
PASS
REVIEW
FAILbased on a documented training baseline.
126 — PowerShell for SOC Analysts
Section titled “126 — PowerShell for SOC Analysts”Focus on:
Get-WinEvent
Where-Object
Group-Object
Select-Object
Export-Csv
JSON127 — PowerShell for Incident Responders
Section titled “127 — PowerShell for Incident Responders”Focus on:
Processes
Services
Network Connections
Event Logs
Files
Hashes
Users
Scheduled Tasks128 — PowerShell for Windows Security Engineers
Section titled “128 — PowerShell for Windows Security Engineers”Focus on:
Users
Groups
Services
Firewall
Defender
Registry
Audit Policy
Configuration Baselines129 — PowerShell for Active Directory Security
Section titled “129 — PowerShell for Active Directory Security”Focus on:
Users
Groups
Computers
Service Accounts
Group Membership
Administrative Relationships
GPO Context130 — PowerShell for Cloud Security
Section titled “130 — PowerShell for Cloud Security”PowerShell also supports Microsoft cloud ecosystems through dedicated modules.
Common security workflows can include:
IDENTITY INVENTORY
ROLE REVIEW
RESOURCE CONFIGURATION
SECURITY EVENTS
POLICY CHECKSUse approved modules and authorized environments.
131 — PowerShell vs Bash
Section titled “131 — PowerShell vs Bash”A simple mental model:
BASH=LINUX + TEXT PIPELINESPOWERSHELL=WINDOWS + OBJECT PIPELINES132 — PowerShell vs Python
Section titled “132 — PowerShell vs Python”Use PowerShell when:
Working Deeply With Windows
Managing Microsoft Services
Querying Windows Objects
Using Native Windows APIs / ModulesUse Python when:
Cross-Platform Automation
Complex Data Processing
General APIs
Larger Security ApplicationsOften both are useful.
133 — PowerShell Security Principles
Section titled “133 — PowerShell Security Principles”Always consider:
WHO RUNS THE SCRIPT?
WHAT PRIVILEGE DOES IT HAVE?
WHAT SYSTEMS DOES IT TOUCH?
WHAT DATA DOES IT READ?
WHAT DATA DOES IT WRITE?
WHAT DOES IT LOG?
WHAT HAPPENS IF IT FAILS?134 — Never Blindly Run Unknown Scripts
Section titled “134 — Never Blindly Run Unknown Scripts”Before executing an unfamiliar script:
READ IT
UNDERSTAND PARAMETERS
CHECK NETWORK CALLS
CHECK FILE OPERATIONS
CHECK REGISTRY OPERATIONS
CHECK PRIVILEGE REQUIREMENTS
CHECK CLEANUPDo not run unknown scripts as Administrator.
135 — 4-Week PowerShell Practice Plan
Section titled “135 — 4-Week PowerShell Practice Plan”| Week | Focus |
|---|---|
| 1 | Cmdlets, Objects, Pipeline, Variables |
| 2 | Files, Processes, Services, Users, Groups |
| 3 | Event Logs, Registry, Networking, AD |
| 4 | Security Automation Project |
PowerShell Readiness Levels
Section titled “PowerShell Readiness Levels”Level 01 — PowerShell Fundamentals
Section titled “Level 01 — PowerShell Fundamentals”You understand:
Cmdlets
Objects
Pipeline
VariablesLevel 02 — Object Processing
Section titled “Level 02 — Object Processing”You can use:
Where-Object
Select-Object
Sort-Object
Group-ObjectLevel 03 — Windows Security
Section titled “Level 03 — Windows Security”You can review:
Users
Groups
Processes
Services
Firewall
DefenderLevel 04 — Security Logs
Section titled “Level 04 — Security Logs”You can:
Query Event Logs
Filter Event IDs
Export Evidence
Summarize EventsLevel 05 — Active Directory
Section titled “Level 05 — Active Directory”You can:
Inventory Users
Review Groups
Inventory Computers
Review Service Accountsin authorized environments.
Level 06 — Security Automation
Section titled “Level 06 — Security Automation”You can build:
Inventory Scripts
Audit Scripts
Log Analysis Scripts
Evidence Collection Scripts
Security ReportsPowerShell for Cybersecurity Checklist
Section titled “PowerShell for Cybersecurity Checklist”Fundamentals
Section titled “Fundamentals”- PowerShell version identified
- Cmdlets understood
- Help system understood
- Objects understood
- Pipeline understood
Programming
Section titled “Programming”- Variables
- Arrays
- Hashtables
- Conditions
- Loops
- Functions
- Parameters
- Get-ChildItem
- Get-Content
- Select-String
- Out-File
- CSV
- JSON
- File hashes
Windows
Section titled “Windows”- Current identity
- System information
- Processes
- Services
- Scheduled tasks
- Local users
- Local groups
- Local administrators
Permissions
Section titled “Permissions”- Get-Acl understood
- File ACLs reviewed
- Registry ACLs reviewed
- Ownership understood
Event Logs
Section titled “Event Logs”- Get-WinEvent
- Security log
- Event ID filtering
- PowerShell logs
- Event exporting
Networking
Section titled “Networking”- IP configuration
- Routes
- DNS
- TCP connections
- Connectivity testing
Security Controls
Section titled “Security Controls”- Defender status
- Firewall profiles
- Audit policy
- Security controls left enabled
Active Directory
Section titled “Active Directory”- Domain context
- Domain controller discovery
- Users
- Groups
- Domain Admins
- Computers
- Service accounts
- GPO context
Secure Automation
Section titled “Secure Automation”- Inputs validated
- Errors handled
- Secrets protected
- Logs sanitized
- Least privilege used
- Unknown scripts reviewed
- Cleanup included
Projects
Section titled “Projects”- Local administrator audit
- Service inventory
- Failed login analyzer
- Defender status report
- Firewall audit
- Security inventory
- Event exporter
- AD inventory
- File hash collection
- Configuration checker
40 PowerShell for Cybersecurity Review Questions
Section titled “40 PowerShell for Cybersecurity Review Questions”- What is PowerShell?
- Why is PowerShell important for Windows security?
- What is a cmdlet?
- What does Verb-Noun mean?
- What is a PowerShell object?
- How is PowerShell’s pipeline different from a text-only shell?
- What does
Get-Membershow? - What does
Where-Objectdo? - What does
Select-Objectdo? - What does
Sort-Objectdo? - What does
Group-Objectdo? - What is a PowerShell array?
- What is a hashtable?
- What is a
PSCustomObject? - Why are
PSCustomObjects useful in reporting? - What does
Get-Processprovide? - What does
Get-Serviceprovide? - Why is
Get-CimInstance Win32_Serviceuseful? - What does
Get-LocalUserprovide? - Why should local Administrators membership be reviewed?
- What does
Get-Aclprovide? - Why are ACLs important in security assessments?
- How does PowerShell access the Windows Registry?
- What does
Get-NetTCPConnectionprovide? - What does
Test-NetConnectiondo? - What is
Get-WinEventused for? - What does event ID 4625 commonly represent?
- What does event ID 4624 commonly represent?
- Why is PowerShell logging valuable for defenders?
- What does
Get-MpComputerStatusprovide? - Why should Defender not be disabled during normal security testing?
- What does
Get-NetFirewallProfileshow? - What is Active Directory?
- How can PowerShell help inventory AD users and groups?
- Why are service accounts important?
- What does
gpresult /rprovide? - Why should PowerShell automation run with least privilege?
- Why should dynamic code execution be treated carefully?
- Why should scripts avoid hard-coded secrets?
- What makes a PowerShell security script repeatable and professional?
Final PowerShell for Cybersecurity Mental Model
Section titled “Final PowerShell for Cybersecurity Mental Model”Remember:
WINDOWS SECURITY DATA ↓POWERSHELL CMDLET ↓OBJECT ↓PIPELINE ↓FILTER ↓SELECT ↓ANALYZE ↓EXPORT ↓SECURITY DECISIONFor automation:
COLLECT ↓VALIDATE ↓NORMALIZE ↓ANALYZE ↓REPORT ↓REVIEWDo not think:
I NEED TO MEMORIZEEVERY POWERSHELL CMDLETThink:
WHAT WINDOWS OBJECTDO I NEED?
WHICH CMDLETRETURNS IT?
WHICH PROPERTYMATTERS?
HOW DO I FILTER IT?
HOW DO I TURN ITINTO A SECURITY RESULT?For example:
WINDOWS HOST ↓Get-LocalGroupMember ↓ADMINISTRATORS ↓REVIEW MEMBERSHIP ↓SECURITY FINDINGor:
SECURITY EVENT LOG ↓Get-WinEvent ↓FILTER EVENT ID ↓GROUP EVENTS ↓INVESTIGATION SUMMARYor:
ACTIVE DIRECTORY ↓USERS + GROUPS ↓PRIVILEGE RELATIONSHIPS ↓SECURITY REVIEWThat is PowerShell for cybersecurity:
WINDOWS OBJECTS +SECURITY CONTEXT +AUTOMATION =REPEATABLE SECURITY OPERATIONSWhat’s Next?
Section titled “What’s Next?”➡️ 04 — JavaScript Fundamentals
The next module moves into the language that powers much of the modern browser and frontend application ecosystem.
You will learn:
JAVASCRIPT BASICS ↓VARIABLES ↓DATA TYPES ↓FUNCTIONS ↓ARRAYS ↓OBJECTS ↓CONDITIONS ↓LOOPS ↓DOM ↓EVENTS ↓BROWSER STORAGE ↓HTTP REQUESTS ↓JSON ↓ASYNC JAVASCRIPT ↓WEB SECURITY CONTEXTThe goal is not to become a frontend developer.
The goal is to understand enough JavaScript to analyze modern web application behavior, client-side logic, API interactions, browser security boundaries, and application security workflows.