4 min read

[Power BI] Data Gateway - Troubleshooting PS script

Table of Contents

πŸ“œ Script

Check the script in GitHub

✨ Key Features

ScenarioCollectsTypical Use-case
1 – Logs onlySystemInfo.txt + Windows Application / System / Security event logs (past 7 days)General health check; offline log review
2 – Live tracesHigh-level network ETL (.etl) + lightweight PerfMon (.blg) during issue reproductionConnectivity issues, performance issues
3 – Full captureEverything from Scenario 2 plus CAPI2/Operational log and all files from Scenario 1Complex scenarios, connectivity issues including SSL/TLS failures, performance issues, general server information

All output is stored in a time-stamped directory:

<base-path>\MSTraces_YYYYMMDD-HHMMSS\

πŸ”§ Prerequisites

  • Windows Server 2019 and above
  • Administrator rights (script checks and exits if not elevated)
  • PowerShell 5.x or newer (comes with Windows)

πŸš€ Quick Start

# 1. Start an elevated PowerShell console
# 2. Run the script
.\OPDG - Environmental Troubleshooting Data Collector.ps1

You will see a banner similar to:

OPDG - Environmental Troubleshooting Data Collector v0.7
─────────────────────────────────────────────────────────
β–ͺ Scenario 1 – System info + core event logs
β–ͺ Scenario 2 – Live network ETL trace + PerfMon
β–ͺ Scenario 3 – Full capture (trace + CAPI2 + logs)

Follow the prompts to choose a scenario and base folder.

πŸ“‚ What Gets Collected?

1. SystemInfo_<timestamp>.txt

A single, human-readable snapshot containing:

SectionDetails
NetworkPrimary IPv4 address, WinHTTP proxy, IE proxy settings
CPU / MemoryPhysical cores, logical processors, total RAM (GB)
OS BuildMajor.Minor.Build.Revision & friendly name
.NET RuntimeHighest installed desktop CLR 4.x version
Firewallnetsh advfirewall show allprofiles dumpβ€”profile states & rules summary
AntivirusAntivirusProduct names from root/SecurityCenter2
Installed ProgramsDisplayName + DisplayVersion from registry keys

Tip: Since it’s plain text, you can search easily for build numbers, proxies, antivirus vendors, etc.

2. Windows Event Logs (.evtx)

ScenarioChannels ExportedTime Range
1Application, System, SecurityLast 7 days
3Same as Scenario 1 plus Microsoft-Windows-CAPI2/OperationalLast 7 days

Logs exported with wevtutil epl preserving metadata.

3. Network Trace (Trace_<PC>_<timestamp>.etl)

Circular ETL trace created with:

netsh trace start scenario=netconnection,internetclient
  • Providers include NDIS, TCPIP, Winsock-AFD, Schannel.
  • Max size: 4 GB (circular, overwrites when full).
  • Capture stops when you type stop.

Open with Wireshark, Microsoft Message Analyzer (retired), or NetMon.

4. Performance Monitor (Perfmon_<timestamp>.blg)

Counter set sampled every 5 seconds:

  • \Processor(_Total)% Processor Time
  • \Memory\Available MBytes
  • \Memory\Committed Bytes
  • \PhysicalDisk(_Total)% Idle Time
  • \PhysicalDisk(_Total)\Current Disk Queue Length

Useful for correlating performance spikes with network traces.

πŸ“ Expected Folder Layout & Sizes

MSTraces_20250618-093245\
β”œβ”€ SystemInfo_20250618-093245.txt             ~  5–20 KB
β”œβ”€ Application_20250618-093245.evtx           ~  1–50 MB
β”œβ”€ System_20250618-093245.evtx                ~  1–50 MB
β”œβ”€ Security_20250618-093245.evtx              ~  1–10 MB
β”œβ”€ Microsoft-Windows-CAPI2_Operational_...    (scenario 3 only)
β”œβ”€ Trace_HOST123_20250618-093245.etl          up to 4 GB (circular)
└─ Perfmon_20250618-093245.blg                ~  2–50 MB

Logs compress wellβ€”use zip/7-zip before uploading.

πŸ› Troubleshooting & FAQ

β€œScript says β€˜Please run as Administrator’ even though I am admin.”

Launch PowerShell with Run as administrator (title bar shows Administrator:). Having admin rights in AD does not automatically elevate your shell.

How do I view .evtx files on another machine?

Copy the file and open with Event Viewer β†’ Action β†’ Open Saved Log….

Can I increase the log retention beyond 7 days?

Yesβ€”search for the variable $logDays in the script and adjust it.

Does the script collect any personal files?

No. It only queries system metadata, registry keys, and Windows logging APIs. No personal files are collected.


⚠️Disclaimer: This tool and its documentation are not official Microsoft guidance. Please consult Microsoft Learn or other official Microsoft resources for authoritative information. Before running this script, review its contents carefully and ensure it aligns with your organization’s internal policies and security standards.