Azure / Azure/azure-powershell

Az.PolicyInsights 2.0.0 Get-AzPolicyRemediation at management-group scope sends api-version 2024-10-01 to Microsoft.Management/managementGroups (unsupported)

Open
#29,850 1 comment 1 reaction 2 assignees Claimed by @a0x1ab View on GitHub
bug customer-reported Policy Insights
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Description

Get-AzPolicyRemediation at management-group scope is broken in Az.PolicyInsights 2.0.0. When listing remediations for a management group it resolves the Microsoft.Management/managementGroups resource using api-version 2024-10-01 — but the Microsoft.Management resource provider does not support that api-version, so the call fails.

**Repro**

Install-Module Az.PolicyInsights -RequiredVersion 2.0.0 -Force
Get-AzPolicyRemediation -ManagementGroupName

**Expected**: MG-scope resolution should use a supported Microsoft.Management api-version (e.g. 2023-04-01), as in 1.7.4. Get-AzPolicyRemediation -ManagementGroupName should return remediations without error.

Every management-group-scoped remediation status check fails. This breaks EPAC New-AzRemediationTasks monitoring for all MG-scoped remediation tasks.

**Environment**

Az.PolicyInsights: 2.0.0 (broken) / 1.7.4 (works)
PowerShell 7 / Linux

Workaround: pin Az.PolicyInsights to 1.7.4.

### Issue script & Debug output

```PowerShell
Get-AzPolicyRemediation_List3: .../Az.PolicyInsights/2.0.0/PolicyInsights.Autorest/custom/Get-AzPolicyRemediation.ps1:280
The resource type 'managementGroups' could not be found in the namespace 'microsoft.management'
for api version '2024-10-01'. The supported api-versions are
'2024-02-01-preview,2023-04-01,2021-04-01,2020-10-01,2020-05-01,2020-02-01,2019-11-01,
2018-03-01-preview,2018-01-01-preview,2017-11-01-preview,2017-08-31-preview,
2017-06-30-preview,2017-05-31-preview,2018-03-01-beta'.
```

### Environment data

```PowerShell
Reproduced in a Linux CI container (custom internal image), PowerShell 7.x (Core).
This is an api-version issue in the generated cmdlet, so it is OS-independent.
```

### Module versions

```PowerShell
Az.PolicyInsights 2.0.0 fails / 1.7.4 works
```

### Error output

```PowerShell

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.