Acquire Triage Data Using Powershell

1. Preparation

  • Launch PowerShell: Open PowerShell as Administrator (powershell.exe or pwsh.exe for PowerShell Core). Right-click the Start menu > "Windows PowerShell (Admin)" or use Run > PowerShell > Ctrl+Shift+Enter.

  • Set Output Location: Define a directory for triage data (e.g., local drive or external USB). Create it with:

    $OutputPath = "D:\TriageOutput"
    New-Item -Path $OutputPath -ItemType Directory -Force
  • Execution Policy: Check with Get-ExecutionPolicy. If restricted (Restricted), bypass it temporarily:

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force
  • Logging: Start a transcript to log commands and output:powershell

    Start-Transcript -Path "$OutputPath\PowerShellTranscript.txt"

2. Define Triage

Objectives

For effective triage, collect artifacts that reveal system state, user activity, potential persistence, and compromise indicators:

  • System info (OS, hardware, users)

  • Running processes and services

  • Network activity (connections, DNS, ARP)

  • Event logs (system, security, application)

  • Registry (persistence, configuration)

  • Filesystem (recent files, prefetch, temp)

  • Scheduled tasks and accounts

Comprehensive Collection Script Below is a detailed PowerShell script (Triage.ps1) to collect these artifacts. Copy this into a .ps1 file or run commands individually.

3. Execute the Collection

  • Run the Script: Save as Triage.ps1 and execute:powershell

  • Alternative: Copy-paste commands into an admin PowerShell session or run individually.

  • Duration: Takes 5-20 minutes depending on system size, event log volume, and filesystem recursion depth.

4. Verify and Analyse

  • Output Check: Inspect $OutputPath for:

    • CSV files (e.g., Processes_20250226_123456.csv)

    • Text files (e.g., Netstat_20250226_123456.txt)

    • Exported files (e.g., Prefetch folder, .reg files)

    • ZIP archive (e.g., TriageData_20250226_123456.zip)

  • Analysis Tools:

    • CSVs: Open in Excel or import with Import-Csv for filtering.

    • Prefetch: Use PEcmd or forensic suites (Autopsy, FTK).

    • Event Logs: Parse with Event Log Explorer or custom scripts.

    • Registry: Import .reg files or analyse CSVs in RegRipper.

5. Advanced Enhancements

  • Memory Dump: Pair with DumpIt or winpmem for RAM capture (PowerShell can’t do this natively):

  • Hash Files: Add MD5 hashes for integrity:

  • Remote Execution: Run on networked systems:

6. Tips and Considerations

  • Scope Control: Adjust -MaxEvents (e.g., 5000 to 1000) or file search depth to speed up collection.

  • Error Handling: ErrorAction SilentlyContinue skips inaccessible areas (e.g., locked files).

  • Live Only: For forensic images, mount them first (e.g., via Arsenal Image Mounter) and adjust paths.

  • Stealth: Use a USB or remote session to minimise footprint; avoid writing to C: if possible.

  • Permissions: Admin rights are required for most cmdlets (e.g., Get-WinEvent, Get-ScheduledTask).

Last updated