Skip to content

Commit d7b0cd6

Browse files
authored
Updated code snippet
1 parent bcdfe01 commit d7b0cd6

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

articles/cost-management-billing/savings-plan/permission-view-manage.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,19 @@ Use the following Azure PowerShell script to give a user Azure RBAC access to al
104104
105105
Import-Module Az.Accounts
106106
Import-Module Az.Resources
107-
107+
108108
Connect-AzAccount -Tenant <TenantId>
109-
110-
$response = Invoke-AzRestMethod -Path /providers/Microsoft.Capacity/reservations?api-version=2020-06-01 -Method GET
111-
109+
$response = Invoke-AzRestMethod -Path /providers/Microsoft.BillingBenefits/savingsPlans?api-version=2022-11-01 -Method GET
112110
$responseJSON = $response.Content | ConvertFrom-JSON
113-
114-
$reservationObjects = $responseJSON.value
115-
116-
foreach ($reservation in $reservationObjects)
111+
$savingsPlanObjects = $responseJSON.value
112+
113+
foreach ($savingsPlan in $savingsPlanObjects)
117114
{
118-
$reservationOrderId = $reservation.id.substring(0, 84)
119-
Write-Host "Assigning Owner role assignment to "$reservationOrderId
120-
New-AzRoleAssignment -Scope $reservationOrderId -ObjectId <ObjectId> -RoleDefinitionName Owner
115+
$savingsPlanOrderId = $savingsPlan.id.substring(0, 84)
116+
Write-Host "Assigning Owner role assignment to "$savingsPlanOrderId
117+
New-AzRoleAssignment -Scope $savingsPlanOrderId -ObjectId <ObjectId> -RoleDefinitionName Owner
121118
}
119+
122120
```
123121

124122
When you use the PowerShell script to assign the ownership role and it runs successfully, a success message isn’t returned.
@@ -161,7 +159,7 @@ Use the following Azure PowerShell script to add a Savings plan Administrator ro
161159
Import-Module Az.Accounts
162160
Import-Module Az.Resources
163161
Connect-AzAccount -Tenant <TenantId>
164-
New-AzRoleAssignment -Scope "/providers/Microsoft.Capacity" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Administrator"
162+
New-AzRoleAssignment -Scope "/providers/Microsoft.BillingBenefits" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Administrator"
165163
```
166164

167165
#### Parameters
@@ -192,7 +190,7 @@ Import-Module Az.Resources
192190
193191
Connect-AzAccount -Tenant <TenantId>
194192
195-
New-AzRoleAssignment -Scope "/providers/Microsoft.Capacity" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Reader"
193+
New-AzRoleAssignment -Scope "/providers/Microsoft.BillingBenefits" -PrincipalId <ObjectId> -RoleDefinitionName "Savings plan Reader"
196194
```
197195

198196
#### Parameters

0 commit comments

Comments
 (0)