Skip to content

[release/v7.6.2] Update PowerShell telemetry to respect the diagnostics and feedback setting on Windows#27438

Merged
daxian-dbw merged 1 commit into
PowerShell:release/v7.6.2from
daxian-dbw:backport/release/v7.6.2/27328-65e6a8055
May 13, 2026
Merged

[release/v7.6.2] Update PowerShell telemetry to respect the diagnostics and feedback setting on Windows#27438
daxian-dbw merged 1 commit into
PowerShell:release/v7.6.2from
daxian-dbw:backport/release/v7.6.2/27328-65e6a8055

Conversation

@daxian-dbw
Copy link
Copy Markdown
Member

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

  • Required tooling change
  • Optional tooling change (include reasoning)

Customer Impact

  • Customer reported
  • Found internally

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.

  • Yes
  • No

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.

  • High
  • Medium
  • Low

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.

Copilot AI review requested due to automatic review settings May 13, 2026 22:08
@daxian-dbw daxian-dbw requested a review from TravisEz13 as a code owner May 13, 2026 22:08
@daxian-dbw daxian-dbw added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ApplicationInsightsTelemetry initialization 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
}
@daxian-dbw daxian-dbw merged commit 0ceb11a into PowerShell:release/v7.6.2 May 13, 2026
36 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.6.2/27328-65e6a8055 branch May 13, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants