You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make ManagementGroupId optional, default to tenant root management group
Change ManagementGroupId from required to optional in both
deployment.ps1 and start-remediation.ps1. When not specified,
the scripts resolve the tenant root management group ID
automatically via (Get-AzContext).Tenant.Id.
Changes:
- deployment.ps1: ManagementGroupId parameter now Mandatory=false;
auto-resolves to tenant root group with informational output
- start-remediation.ps1: same parameter change and auto-resolve
- README.md: updated both parameter tables (Required=No, default
shown as 'Tenant root group'); simplified examples to omit
ManagementGroupId where the default suffices; added explicit
management group examples for users who need a custom scope
|`ManagementGroupId`|Yes|N/A | Any valid management group ID | Scope where the policy definition is created. |
24
+
|`ManagementGroupId`|No|Tenant root group | Any valid management group ID | Scope where the policy definition is created. Defaults to the tenant root management group when not specified. |
25
25
|`ExtensionType`| No |`Both`|`Windows`, `Linux`, `Both`| Targets the Arc SQL extension platform. When `Both` (default), a single policy definition and assignment covers both platforms. When a specific type is selected, the naming and scope are tailored to that platform. |
26
26
|`SubscriptionId`| No | Not set | Any valid subscription ID | If provided, policy assignment scope is the subscription. |
27
27
|`TargetLicenseType`| Yes | N/A |`Paid`, `PAYG`| Target `LicenseType` value to enforce. |
@@ -56,11 +56,14 @@ Connect-AzAccount
56
56
```
57
57
58
58
```powershell
59
-
# Example: target both platforms (default)
59
+
# Example: target both platforms (default), using tenant root management group
Note: `scripts/deployment.ps1` automatically grants required roles to the policy assignment managed identity at assignment scope, preventing common `PolicyAuthorizationFailed` errors during DeployIfNotExists deployments.
|`ManagementGroupId`|Yes|N/A | Any valid management group ID | Used to resolve the policy definition/assignment naming context. |
97
+
|`ManagementGroupId`|No|Tenant root group | Any valid management group ID | Used to resolve the policy definition/assignment naming context. Defaults to the tenant root management group when not specified. |
95
98
|`ExtensionType`| No |`Both`|`Windows`, `Linux`, `Both`| Must match the platform used for the assignment. When `Both` (default), remediates the combined assignment. |
96
99
|`SubscriptionId`| No | Not set | Any valid subscription ID | If provided, remediation runs at subscription scope. |
97
100
|`TargetLicenseType`| Yes | N/A |`Paid`, `PAYG`| Must match the assignment target license type. |
98
101
|`GrantMissingPermissions`| No |`false`| Switch (`present`/`not present`) | If set, checks and assigns missing required roles before remediation. |
99
102
100
103
```powershell
101
-
# Example: remediate both platforms (default)
104
+
# Example: remediate both platforms (default), using tenant root management group
Copy file name to clipboardExpand all lines: samples/manage/azure-arc-enabled-sql-server/compliance/arc-sql-license-type-compliance/scripts/deployment.ps1
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
param(
2
-
[Parameter(Mandatory=$true)]
2
+
[Parameter(Mandatory=$false)]
3
3
[ValidateNotNullOrEmpty()]
4
4
[string]$ManagementGroupId,
5
5
@@ -23,6 +23,11 @@ param(
23
23
[switch]$SkipManagedIdentityRoleAssignment
24
24
)
25
25
26
+
if (-not$PSBoundParameters.ContainsKey('ManagementGroupId')) {
27
+
$ManagementGroupId= (Get-AzContext).Tenant.Id
28
+
Write-Output"ManagementGroupId not specified. Using tenant root management group: $ManagementGroupId"
Copy file name to clipboardExpand all lines: samples/manage/azure-arc-enabled-sql-server/compliance/arc-sql-license-type-compliance/scripts/start-remediation.ps1
+6-1Lines changed: 6 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
param(
2
-
[Parameter(Mandatory=$true)]
2
+
[Parameter(Mandatory=$false)]
3
3
[ValidateNotNullOrEmpty()]
4
4
[string]$ManagementGroupId,
5
5
@@ -31,6 +31,11 @@ param(
31
31
[switch]$GrantMissingPermissions
32
32
)
33
33
34
+
if (-not$PSBoundParameters.ContainsKey('ManagementGroupId')) {
35
+
$ManagementGroupId= (Get-AzContext).Tenant.Id
36
+
Write-Output"ManagementGroupId not specified. Using tenant root management group: $ManagementGroupId"
0 commit comments