Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
adityapatwardhan merged 1 commit into
PowerShell:release/v7.5.7PowerShell/PowerShell:release/v7.5.7from
adityapatwardhan:backport/release/v7.5.7/27328-65e6a8055adityapatwardhan/PowerShell:backport/release/v7.5.7/27328-65e6a8055Copy head branch name to clipboard
May 19, 2026
Merged

[release/v7.5.7] Update PowerShell telemetry to respect the diagnostics and feedback setting on Windows#27472
adityapatwardhan merged 1 commit into
PowerShell:release/v7.5.7PowerShell/PowerShell:release/v7.5.7from
adityapatwardhan:backport/release/v7.5.7/27328-65e6a8055adityapatwardhan/PowerShell:backport/release/v7.5.7/27328-65e6a8055Copy head branch name to clipboard

Conversation

@adityapatwardhan
Copy link
Copy Markdown
Member

Backport of #27328 to release/v7.5.7

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)

Customer Impact

  • Customer reported
  • Found internally

This change ensures telemetry honors the Windows diagnostics and feedback setting and avoids sending telemetry when disabled.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Validated by cherry-pick resolution, existing telemetry tests updated in the commit, and build/runtime behavior remains gated by telemetry enablement checks.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

The change is limited to telemetry initialization gating and ETW logging paths, with no impact on core command execution.

Merge Conflicts

Resolved conflict in src/System.Management.Automation/utils/Telemetry.cs by taking the PR version and preserving release branch compatibility.

Copilot AI review requested due to automatic review settings May 18, 2026 17:43
@adityapatwardhan adityapatwardhan added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label May 18, 2026
Comment thread src/System.Management.Automation/utils/Telemetry.cs Outdated
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 to release/v7.5.7 that gates PowerShell telemetry on Windows based on the OS “Diagnostics & feedback” data-collection policy, using a WinRT API wrapper and emitting an ETW operational error event when the policy query fails.

Changes:

  • Add a WinRT/COM interop wrapper (WindowsDataCollectionSetting) to query Windows diagnostic data-collection permission and use it during telemetry initialization.
  • Add a new ETW operational error event/task for failures querying the Windows setting, and update the instrumentation manifest/resources accordingly.
  • Update telemetry Pester tests to avoid running in environments where OS telemetry policy disables PowerShell telemetry.

Reviewed changes

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

Show a summary per file
File Description
test/powershell/engine/Basic/Telemetry.Tests.ps1 Adds OS telemetry-level detection and attempts to skip telemetry tests when OS policy disables telemetry.
src/System.Management.Automation/utils/WindowsDataCollectionSetting.cs Adds WinRT activation factory interop to check Windows diagnostics/data-collection policy and logs ETW on failure.
src/System.Management.Automation/utils/Telemetry.cs Gates telemetry on Windows via WindowsDataCollectionSetting and adjusts cache-path usage.
src/System.Management.Automation/engine/remoting/common/PSETWTracer.cs Adds new PSEventId and PSTask for telemetry-setting failures.
src/System.Management.Automation/CoreCLR/CorePsPlatform.cs Fixes COM initialization balancing comment/logic for STA support detection.
src/PowerShell.Core.Instrumentation/PowerShell.Core.Instrumentation.man Adds ETW event/task/template/resource strings for the new telemetry-setting error event (plus related manifest convergence).

Comment thread src/System.Management.Automation/utils/Telemetry.cs
Comment on lines 39 to +54
Describe "Telemetry for shell startup" -Tag CI {
BeforeAll {
$skipTelemetryTests = $false

if ($IsWindows) {
## Skip telemetry tests if the OS telemetry level is less than 2 (Enhanced) -- PS telemetry is disabled in this case.
$osTelemetryLevel = Get-OSTelemetryLevel
$skipTelemetryTests = $osTelemetryLevel -lt 2
}

if ($skipTelemetryTests) {
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["it:skip"] = $true
return
}

Comment on lines +19 to +33
# 1. Check the "Managed" Policy (Group Policy)
if (Test-Path $gpoPath) {
$gpoValue = Get-ItemProperty -Path $gpoPath -Name $valueName -ErrorAction SilentlyContinue
if ($gpoValue -and $gpoValue.$valueName) {
return [int]$gpoValue.$valueName
}
}

# 2. Check the "User/System" Preference (Settings App)
if (Test-Path $sysPath) {
$sysValue = Get-ItemProperty -Path $sysPath -Name $valueName -ErrorAction SilentlyContinue
if ($sysValue -and $sysValue.$valueName) {
return [int]$sysValue.$valueName
}
}
Comment thread src/System.Management.Automation/utils/Telemetry.cs
@adityapatwardhan adityapatwardhan force-pushed the backport/release/v7.5.7/27328-65e6a8055 branch from 3c4da0d to 291d422 Compare May 18, 2026 18:10
Comment thread src/System.Management.Automation/utils/Telemetry.cs Outdated
@adityapatwardhan adityapatwardhan force-pushed the backport/release/v7.5.7/27328-65e6a8055 branch from 5385850 to f62eb15 Compare May 19, 2026 17:32
@adityapatwardhan adityapatwardhan merged commit c3d3fdd into PowerShell:release/v7.5.7 May 19, 2026
35 checks passed
@adityapatwardhan adityapatwardhan deleted the backport/release/v7.5.7/27328-65e6a8055 branch May 19, 2026 18:32
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.