Skip to content

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

Open
adityapatwardhan wants to merge 2 commits into
PowerShell:release/v7.4.16from
adityapatwardhan:backport/release/v7.4.16/27328-65e6a8055
Open

[release/v7.4.16] Update PowerShell telemetry to respect the diagnostics and feedback setting on Windows#27430
adityapatwardhan wants to merge 2 commits into
PowerShell:release/v7.4.16from
adityapatwardhan:backport/release/v7.4.16/27328-65e6a8055

Conversation

@adityapatwardhan
Copy link
Copy Markdown
Member

Backport of #27328 to release/v7.4.16

Triggered by @adityapatwardhan 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)

No tooling workflow changes required for consumers; this backport updates runtime telemetry initialization behavior and ETW manifest/resources.

Customer Impact

  • Customer reported
  • Found internally

Ensures telemetry behavior on Windows respects the diagnostics and feedback setting, aligning with expected privacy/collection controls.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Cherry-pick applied with one conflict in Telemetry.cs resolved to preserve release-branch initialization while adding diagnostics-setting gating. Included telemetry test updates from the original PR; build and CI validation will run on the backport PR.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Touches telemetry initialization and ETW related code paths on Windows; behavior change is intentional but affects startup/telemetry enabling logic.

Merge Conflicts

Resolved a conflict in src/System.Management.Automation/utils/Telemetry.cs by combining release/v7.4.16 branch structure with the original PR's Windows diagnostics-and-feedback gate logic, then completed cherry-pick without remaining conflict markers.

Copilot AI review requested due to automatic review settings May 13, 2026 20:15
@adityapatwardhan adityapatwardhan 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 release/v7.4.16. Updates PowerShell telemetry on Windows to respect the OS-level diagnostics and feedback setting via the WinRT IPlatformDiagnosticsAndUsageDataSettingsStatics API, with an ETW event for failure logging.

Changes:

  • Add WindowsDataCollectionSetting using source-generated COM interop to query the WinRT diagnostics setting; gate telemetry on Enhanced level.
  • Add new ETW event/task (Telemetry_Setting_Error, Telemetry) plus manifest entries (also syncs WDAC entries to match PowerShell-Native).
  • Fix CoUninitialize balancing in IsStaSupported (>=0 instead of >0) and update Telemetry tests to skip when OS telemetry level < Enhanced.

Reviewed changes

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

Show a summary per file
File Description
src/System.Management.Automation/utils/WindowsDataCollectionSetting.cs New WinRT interop wrapper to query platform data collection level.
src/System.Management.Automation/utils/Telemetry.cs Gates CanSendTelemetry on the Windows diagnostics setting.
src/System.Management.Automation/engine/remoting/common/PSETWTracer.cs Adds Telemetry_Setting_Error event ID and Telemetry task.
src/System.Management.Automation/CoreCLR/CorePsPlatform.cs Balances CoUninitialize for both S_OK and S_FALSE results.
src/PowerShell.Core.Instrumentation/PowerShell.Core.Instrumentation.man Adds telemetry event/task/template; syncs WDAC entries.
test/powershell/engine/Basic/Telemetry.Tests.ps1 Skips telemetry tests when OS telemetry level is below Enhanced.

@daxian-dbw
Copy link
Copy Markdown
Member

Backporting this PR should wait after #26269 gets backported and merged.
The changes to Telemetry.cs in this PR depends on the changes in #26269.

@adityapatwardhan
Copy link
Copy Markdown
Member Author

close, this need to be done after #27453

@adityapatwardhan adityapatwardhan deleted the backport/release/v7.4.16/27328-65e6a8055 branch May 14, 2026 20:22
@adityapatwardhan adityapatwardhan restored the backport/release/v7.4.16/27328-65e6a8055 branch May 15, 2026 21:53
@adityapatwardhan adityapatwardhan force-pushed the backport/release/v7.4.16/27328-65e6a8055 branch from 4b1a642 to ca0e1c1 Compare May 15, 2026 22:05
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.

4 participants