PowerShell for Security Operations
The commands defenders run during investigations and triage, organized by ATT&CK tactic. 31 commands across 9 tactics, each with the syntax, what it reveals, and what to look for. No account needed.
Run elevated where required. These are read-and-collect commands for investigation and triage, paired with what each output reveals and how to read it. Organized by the ATT&CK tactic the command helps you investigate.
Discovery 6
Get-ComputerInfo | Select-Object CsName, OsName, OsVersion, OsBuildNumber, CsDomain, CsWorkgroup, TimeZoneGet-NetIPConfiguration | Select-Object InterfaceAlias, IPv4Address, DNSServer, DefaultGatewayGet-ADDomainController -Filter * | Select-Object Name, IPv4Address, Site, OperatingSystem, IsGlobalCatalogGet-LocalUser | Select-Object Name, Enabled, LastLogon, PasswordLastSet, Description
Get-LocalGroupMember -Group "Administrators" | Select-Object Name, ObjectClass, PrincipalSourceGet-ADUser -Filter * -Properties LastLogonDate, PasswordLastSet, Enabled, MemberOf | Where-Object { $_.Enabled -eq $true } | Select-Object Name, SamAccountName, LastLogonDate, PasswordLastSetGet-SmbShare | Select-Object Name, Path, Description
Get-SmbOpenFile | Select-Object ClientComputerName, ClientUserName, PathPersistence 5
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -ErrorAction SilentlyContinue
Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -ErrorAction SilentlyContinue
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" -ErrorAction SilentlyContinueGet-ScheduledTask | Where-Object { $_.State -ne "Disabled" } | Select-Object TaskName, TaskPath, State, @{N="Actions";E={$_.Actions.Execute + " " + $_.Actions.Arguments}} | Format-ListGet-WmiObject Win32_Service | Where-Object { $_.PathName -match "temp|appdata|programdata|users" } | Select-Object Name, DisplayName, State, StartMode, PathNameGet-WMIObject -Namespace root\subscription -Class __EventFilter
Get-WMIObject -Namespace root\subscription -Class __EventConsumer
Get-WMIObject -Namespace root\subscription -Class __FilterToConsumerBindingGet-ChildItem "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup"
Get-ChildItem "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"Credential Access 3
reg query "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest" /v UseLogonCredential
Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" | Select-Object RunAsPPL, LmCompatibilityLevelklist
klist sessionsGet-ADUser -Filter { ServicePrincipalName -ne "$null" } -Properties ServicePrincipalName, PasswordLastSet | Select-Object SamAccountName, ServicePrincipalName, PasswordLastSet, EnabledExecution 3
Get-WmiObject Win32_Process | Select-Object ProcessId, Name, CommandLine, @{N="ParentPID";E={$_.ParentProcessId}} | Sort-Object ParentPID | Format-ListGet-ExecutionPolicy -List
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" -Name ExecutionPolicy -ErrorAction SilentlyContinueGet-ChildItem -Path C:\Windows\Temp, $env:TEMP, $env:APPDATA -Include *.exe,*.dll,*.ps1,*.bat,*.vbs -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-7) } | Select-Object FullName, LastWriteTime, LengthLateral Movement 4
Get-NetTCPConnection -State Established | Select-Object LocalAddress, LocalPort, RemoteAddress, RemotePort, OwningProcess, @{N="Process";E={(Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue).ProcessName}} | Sort-Object RemoteAddressGet-ItemProperty "HKCU:\Software\Microsoft\Terminal Server Client\Servers\*" -ErrorAction SilentlyContinue | Select-Object PSChildName, UsernameHint
Get-WinEvent -LogName "Microsoft-Windows-TerminalServices-LocalSessionManager/Operational" -MaxEvents 50 | Select-Object TimeCreated, Id, MessageGet-SmbSession | Select-Object ClientComputerName, ClientUserName, NumOpens
Get-SmbOpenFile | Select-Object ClientComputerName, ClientUserName, PathGet-WSManInstance -ResourceURI shell -Enumerate
Get-WinEvent -LogName "Microsoft-Windows-WinRM/Operational" -MaxEvents 20 | Select-Object TimeCreated, Id, MessageCollection 2
Get-ChildItem "$env:APPDATA\Microsoft\Windows\Recent" -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object Name, LastWriteTime -First 30Get-ChildItem -Path C:\Users -Include *.zip,*.rar,*.7z,*.tar,*.gz -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.Length -gt 10MB } | Select-Object FullName, @{N="SizeMB";E={[math]::Round($_.Length/1MB,1)}}, LastWriteTimeDefense Evasion 3
Get-MpComputerStatus | Select-Object RealTimeProtectionEnabled, AntivirusEnabled, AntispywareEnabled, BehaviorMonitorEnabled
Get-MpPreference | Select-Object -ExpandProperty ExclusionPath
Get-MpPreference | Select-Object -ExpandProperty ExclusionProcessGet-WinEvent -ListLog Security,System,Application,"Microsoft-Windows-PowerShell/Operational","Microsoft-Windows-Sysmon/Operational" -ErrorAction SilentlyContinue | Select-Object LogName, IsEnabled, RecordCount, FileSize, LastWriteTimeGet-ChildItem -Path C:\Users -Force -Hidden -Recurse -ErrorAction SilentlyContinue | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-7) } | Select-Object FullName, LastWriteTime, Length
Get-Item -Path C:\Users\*\Desktop\* -Stream * -ErrorAction SilentlyContinue | Where-Object { $_.Stream -ne ":$DATA" }Exfiltration 2
Get-DnsClientCache | Select-Object Entry, RecordName, RecordType, Data | Sort-Object EntryGet-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Enum\USBSTOR\*\*" -ErrorAction SilentlyContinue | Select-Object FriendlyName, @{N="Serial";E={$_.PSChildName}}, ContainerIDContainment 3
Disable-ADAccount -Identity "compromised_user"
Search-ADAccount -LockedOut | Unlock-ADAccount# Microsoft Graph PowerShell
Revoke-MgUserSignInSession -UserId "user@domain.com"
# Reset password
Update-MgUser -UserId "user@domain.com" -PasswordProfile @{ ForceChangePasswordNextSignIn = $true }Test-NetConnection -ComputerName "isolated-host" -Port 445
Get-NetFirewallRule | Where-Object { $_.Action -eq "Block" -and $_.Enabled -eq "True" } | Select-Object DisplayName, DirectionFrom running commands to running the investigation
These collect the evidence. Windows Endpoint Investigation teaches the method: correlating what they return into a defensible account of what happened on the host, and proving it. Built by cybersecurity professionals who still do the job.
Explore the courseWeekly security engineering insights
Detection techniques, architecture patterns, and operational judgment, every Tuesday.
No spam. Unsubscribe anytime.