Collect a Windows Endpoint First-Response Snapshot
Before you begin
- Applies to:Authorized Windows endpoint collection during first response.
- Where to start:Open an approved administrative session on the affected endpoint and follow the incident lead's containment direction.
- What you need:Have a case ID and restricted evidence location. Record who collects the snapshot and when.
Guide tools
When a Windows endpoint shows signs of compromise, collect a focused record of its current state before changing it where your incident plan permits. This snapshot includes host details, processes, network connections, Defender status, and recent system events.
Use an approved administrative session, follow the incident lead’s containment direction, and store the files in a restricted case location. Live response commands can affect the system and do not replace a forensic image or documented evidence-handling process.
Prepare an Evidence Collection Directory
Evidence HandlingOpen elevated PowerShell, create a uniquely named folder under ProgramData, and restrict inherited permissions so only Local System and local Administrators can read the collection. The random suffix prevents a same-second rerun from reusing an earlier case folder. Keep the shell open for the remaining steps so the case path stays available.
$ErrorActionPreference = 'Stop'$caseDir = Join-Path $env:ProgramData ('IR\' + (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + [guid]::NewGuid().ToString('N'))New-Item -ItemType Directory -Path $caseDir -ErrorAction Stop | Out-Null& icacls.exe $caseDir /inheritance:r /grant:r '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F'if ($LASTEXITCODE -ne 0) { throw "icacls failed with exit code $LASTEXITCODE; do not continue collecting into this directory." }Get-Acl $caseDir | Format-List Owner, AccessToString@( "Collector: $env:USERDOMAIN\$env:USERNAME" "Started UTC: $([DateTime]::UtcNow.ToString('o'))") | Set-Content -Path (Join-Path $caseDir 'collection-notes.txt') -ErrorAction Stop❯ Illustrative Output (Results Vary)
processed file: C:\ProgramData\IR\20261004-101500-71e85e84742b4c14a03097e2b7a41f61Successfully processed 1 filesCapture the Current Endpoint State
System TriageSave basic system information, active processes, TCP connections, and local UDP endpoints with their owning process IDs. UDP is connectionless, so this records local endpoints rather than remote peer sessions. These queries do not terminate processes or change firewall rules, though collecting live state can update system metadata and may expose sensitive command lines or addresses.
Get-ComputerInfo | Select-Object CsName, WindowsProductName, WindowsVersion, OsBuildNumber, OsLastBootUpTime | Format-List | Out-File (Join-Path $caseDir 'host.txt')
Get-CimInstance Win32_Process | Select-Object ProcessId, ParentProcessId, ExecutablePath, CreationDate, CommandLine | Export-Csv -NoTypeInformation (Join-Path $caseDir 'processes.csv')
Get-NetTCPConnection | Select-Object State, LocalAddress, LocalPort, RemoteAddress, RemotePort, OwningProcess | Export-Csv -NoTypeInformation (Join-Path $caseDir 'tcp-connections.csv')
Get-NetUDPEndpoint | Select-Object LocalAddress, LocalPort, OwningProcess | Export-Csv -NoTypeInformation (Join-Path $caseDir 'udp-endpoints.csv')❯ Illustrative Output (Results Vary)
host.txtprocesses.csvtcp-connections.csvudp-endpoints.csvCollect Security and Event-Log Context
Security TelemetryRecord Defender’s current status when the module is present and collect a bounded period of recent System events. Adjust the time window to the suspected activity timeline. Event timestamps are converted to UTC ISO 8601 in the export so they can be compared with the UTC collection note; note any event-log access errors.
if (Get-Command Get-MpComputerStatus -ErrorAction SilentlyContinue) { Get-MpComputerStatus | Select-Object AMServiceEnabled, AntivirusEnabled, RealTimeProtectionEnabled, AntivirusSignatureLastUpdated | Format-List | Out-File (Join-Path $caseDir 'defender-status.txt')} else { 'Get-MpComputerStatus is unavailable on this endpoint.' | Set-Content (Join-Path $caseDir 'defender-status.txt')}
$since = (Get-Date).AddHours(-2)Get-WinEvent -FilterHashtable @{ LogName = 'System' StartTime = $since} -MaxEvents 500 -ErrorAction Continue | Select-Object @{Name='TimeCreatedUtc'; Expression={ $_.TimeCreated.ToUniversalTime().ToString('o') }}, Id, ProviderName, LevelDisplayName, Message | Export-Csv -NoTypeInformation (Join-Path $caseDir 'recent-system-events.csv')❯ Illustrative Output (Results Vary)
defender-status.txtrecent-system-events.csvCreate a SHA-256 Manifest
Integrity CheckHash the collected files and immediately verify the manifest. If additional evidence is added later, create a new manifest and document the action in the case notes. A matching hash detects later changes to these files; it does not establish that collection was complete or that the live host was trustworthy.
$manifest = Join-Path $caseDir 'SHA256SUMS.csv'if (Test-Path -LiteralPath $manifest) { throw "Manifest already exists; inspect it instead of overwriting it: $manifest" }Get-ChildItem -Path $caseDir -File | Where-Object Name -ne 'SHA256SUMS.csv' | Get-FileHash -Algorithm SHA256 -ErrorAction Stop | Export-Csv -NoTypeInformation -NoClobber -ErrorAction Stop -Path $manifest
$verification = Import-Csv -LiteralPath $manifest -ErrorAction Stop | ForEach-Object { $actual = (Get-FileHash -LiteralPath $_.Path -Algorithm SHA256 -ErrorAction Stop).Hash $verified = ($actual -eq $_.Hash) if (-not $verified) { throw "SHA-256 mismatch for $($_.Path); preserve the files and investigate." } [pscustomobject]@{ File = Split-Path $_.Path -Leaf Verified = $verified }}$verification❯ Illustrative Output (Results Vary)
File Verified---- --------collection-notes.txt Truedefender-status.txt Truehost.txt Trueprocesses.csv Truerecent-system-events.csv Truetcp-connections.csv Trueudp-endpoints.csv TrueYour feedback keeps these production procedures accurate and battle-tested.