[release/v7.6.2] Update PowerShell telemetry to respect the diagnostics and feedback setting on Windows#27438
Merged
daxian-dbw merged 1 commit intoMay 13, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Backport of #27328 to the release/v7.6.2 branch to ensure PowerShell telemetry on Windows respects the OS “Diagnostics & feedback” (diagnostic data collection) setting, with a safe fallback that disables telemetry and emits an Operational ETW error event if the WinRT query fails.
Changes:
- Add a Windows-only WinRT/COM interop helper (
WindowsDataCollectionSetting) to query whether diagnostics collection is permitted. - Gate
ApplicationInsightsTelemetryinitialization on the Windows diagnostics setting (in addition to the existing env var and cache-path checks). - Add/align ETW event/task definitions and update tests to skip telemetry UUID file assertions when OS telemetry policy disables telemetry.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
test/powershell/engine/Basic/Telemetry.Tests.ps1 |
Adds OS telemetry policy detection and skips the suite when OS policy disables telemetry. |
src/System.Management.Automation/utils/WindowsDataCollectionSetting.cs |
Implements WinRT activation + CanCollectDiagnostics query with ETW logging on failure. |
src/System.Management.Automation/utils/Telemetry.cs |
Uses WindowsDataCollectionSetting to gate CanSendTelemetry on Windows. |
src/System.Management.Automation/engine/remoting/common/PSETWTracer.cs |
Adds new ETW PSEventId and PSTask for telemetry-setting failures. |
src/System.Management.Automation/CoreCLR/CorePsPlatform.cs |
Fixes COM uninitialization balancing for CoInitializeEx success cases (including S_FALSE). |
src/PowerShell.Core.Instrumentation/PowerShell.Core.Instrumentation.man |
Adds the telemetry-setting ETW event resources (and aligns related ETW manifest entries). |
Comment on lines
+20
to
+24
| if (Test-Path $gpoPath) { | ||
| $gpoValue = Get-ItemProperty -Path $gpoPath -Name $valueName -ErrorAction SilentlyContinue | ||
| if ($gpoValue -and $gpoValue.$valueName) { | ||
| return [int]$gpoValue.$valueName | ||
| } |
Comment on lines
+28
to
+32
| if (Test-Path $sysPath) { | ||
| $sysValue = Get-ItemProperty -Path $sysPath -Name $valueName -ErrorAction SilentlyContinue | ||
| if ($sysValue -and $sysValue.$valueName) { | ||
| return [int]$sysValue.$valueName | ||
| } |
andyleejordan
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #27328 to release/v7.6.2
Triggered by @daxian-dbw on behalf of @daxian-dbw
Original CL Label: CL-General
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Customer Impact
PowerShell telemetry now respects the Windows diagnostics and feedback privacy setting. When the user has opted out of diagnostic data collection at the OS level, PowerShell telemetry is disabled accordingly.
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Verified via the original PR. The behavior can only be tested interactively by toggling the Windows diagnostics and feedback privacy setting and observing whether telemetry is enabled or disabled. An ETW event is emitted when the WinRT API call fails.
Risk
REQUIRED: Check exactly one box.
Adds a new WinRT API call path in telemetry initialization. An ETW event is logged and telemetry is disabled if the API call fails, which is the safe fallback. Core engine change but well-guarded.