Skip to content

Adding log files for capturing Windows ML logs - #602

Merged
Andrew Leader (andrewleader) merged 5 commits into
mainfrom
user/aleader/winml-logs
Feb 26, 2026
Merged

Andrew Leader (andrewleader) merged 5 commits into
mainfrom
user/aleader/winml-logs

Conversation

@andrewleader

Copy link
Copy Markdown
Contributor

Description

Adding the log files needed for developers to capture Windows ML logs for diagnostic purposes. The instructions for using these logs will be published on Microsoft Learn after this PR is merged. Microsoft Learn docs are already authored and tested and reviewed.

Target Release

Immediately (applicable to 1.8).

Checklist

Note that /azp run currently isn't working for this repo.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Samples/WindowsML/capture-logs diagnostics drop (profiles + helper script) and links it from the Windows ML sample docs so developers can capture Windows ML/ONNX diagnostic traces and generate a summarized rundown log.

Changes:

  • Adds a WPR profile (WinML.wprp) for capturing Windows ML + ONNX/ORT provider events.
  • Adds a PowerShell helper (Get-WinMLRundown.ps1) to export ETL data via WPA exporter and generate a consolidated log.
  • Updates repo documentation to surface the new “Capture Logs” resource under Windows ML.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Samples/WindowsML/capture-logs/WinML.wprp New WPR profile defining providers/collectors for WinML/ONNX/ORT diagnostics.
Samples/WindowsML/capture-logs/README.md Documents the capture-logs artifacts and points to Microsoft Learn instructions.
Samples/WindowsML/capture-logs/Get-WinMLRundown.ps1 Exports ETL → CSV and merges/renames fields into a single rundown log.
Samples/WindowsML/README.md Adds a “Diagnostics” section linking to capture-logs.
README.md Adds a top-level link to the Windows ML capture-logs resource.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Write-Host " Destination: $installerPath"

try {
Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath -UseBasicParsing

Copilot AI Feb 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invoke-WebRequest -UseBasicParsing is not supported in PowerShell 6+/7+ (the parameter was removed), which will cause this script to fail when run under modern PowerShell. If you need compatibility with both Windows PowerShell 5.1 and PowerShell 7, gate the parameter based on availability or avoid it entirely.

Suggested change
Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath -UseBasicParsing
if ($PSVersionTable.PSVersion.Major -lt 6) {
Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath -UseBasicParsing
} else {
Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath
}

Copilot uses AI. Check for mistakes.
Comment on lines +160 to +165
# Step 2: Get all CSV files
$csvFiles = Get-ChildItem -Path $OutputFolder -Filter *.csv

if ($csvFiles.Count -eq 0) {
Set-Content -Path $LogFilePath -Value "No CSV files found."
exit

Copilot AI Feb 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script invokes wpaexporter.exe but doesn’t check whether it succeeded (e.g., via $LASTEXITCODE) before continuing. If export fails, the script falls through to “No CSV files found.” and exits, which can mask the underlying failure; consider checking the exit code and writing a clearer error + returning a non-zero exit code.

Suggested change
# Step 2: Get all CSV files
$csvFiles = Get-ChildItem -Path $OutputFolder -Filter *.csv
if ($csvFiles.Count -eq 0) {
Set-Content -Path $LogFilePath -Value "No CSV files found."
exit
if ($LASTEXITCODE -ne 0) {
$errorMessage = "wpaexporter.exe failed with exit code $LASTEXITCODE."
Write-Host $errorMessage
if ($LogFilePath) {
Set-Content -Path $LogFilePath -Value $errorMessage
}
exit $LASTEXITCODE
}
# Step 2: Get all CSV files
$csvFiles = Get-ChildItem -Path $OutputFolder -Filter *.csv
if ($csvFiles.Count -eq 0) {
Set-Content -Path $LogFilePath -Value "No CSV files found after export."
exit 1

Copilot uses AI. Check for mistakes.
Comment on lines +261 to +266
exit
}

if (-not ($allData | Get-Member -Name "Process")) {
Set-Content -Path $LogFilePath -Value "No 'Process' column found."
exit

Copilot AI Feb 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several error paths call exit without an explicit non-zero status (e.g., when no CSV files/data/Process column are found). This can cause CI/scripts to treat failures as success. Use a non-zero exit code for these failure cases (or throw) so callers can reliably detect failure.

Suggested change
exit
}
if (-not ($allData | Get-Member -Name "Process")) {
Set-Content -Path $LogFilePath -Value "No 'Process' column found."
exit
exit 1
}
if (-not ($allData | Get-Member -Name "Process")) {
Set-Content -Path $LogFilePath -Value "No 'Process' column found."
exit 1

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +84
$installerPath = "$env:TEMP\adksetup.exe"

Write-Host "Downloading Windows ADK installer..."
Write-Host " URL: $adkUrl"
Write-Host " Destination: $installerPath"

try {
Invoke-WebRequest -Uri $adkUrl -OutFile $installerPath -UseBasicParsing
Write-Host " [OK] Download complete" -ForegroundColor Green
} catch {
Write-Host "Failed to download Windows ADK installer: $_" -ForegroundColor Red
throw
}

Write-Host "Installing Windows Performance Toolkit feature..."
Write-Host " This may take a few minutes..."

$installArgs = "/quiet /norestart /features OptionId.WindowsPerformanceToolkit"
Write-Host " Running: $installerPath $installArgs"

$process = Start-Process -FilePath $installerPath -ArgumentList $installArgs -Wait -PassThru

if ($process.ExitCode -eq 0 -or $process.ExitCode -eq 3010) {
Write-Host " [OK] Installation complete (Exit code: $($process.ExitCode))" -ForegroundColor Green
} else {
Write-Host "Installation failed with exit code: $($process.ExitCode)" -ForegroundColor Red
throw "ADK installation failed"
}

Copilot AI Feb 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script downloads an installer (via fwlink) and runs a silent install (/quiet) of the Windows ADK feature. That’s a high-risk pattern for a sample utility because it executes downloaded code without any explicit user confirmation or integrity verification. Consider removing auto-install and requiring manual install, or at minimum add an explicit opt-in prompt and validate the downloaded binary (e.g., Authenticode signature/publisher) before executing it.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@andrewleader
Andrew Leader (andrewleader) merged commit 177b65d into main Feb 26, 2026
4 checks passed
@andrewleader
Andrew Leader (andrewleader) deleted the user/aleader/winml-logs branch February 26, 2026 23:06
shisan (qiutongMS) pushed a commit that referenced this pull request Aug 25, 2026
Import the stable WPR and WPA profiles from main PR #602, link them from the repository documentation, and harden rundown conversion so it does not install system components or delete caller-owned CSV files. Record targeted validation and the administrator-only WPR capture follow-up.

Source-commit: 177b65d

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants