Skip to content

Commit 33a5c53

Browse files
committed
move to psh v2 syntax
1 parent 12a9689 commit 33a5c53

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

articles/active-directory/governance/entitlement-management-access-package-create.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,18 @@ You can create an access package by using Microsoft Graph. A user in an appropri
151151

152152
### Create an access package by using Microsoft PowerShell
153153

154-
You can also create an access package in PowerShell by using the cmdlets from the [Microsoft Graph PowerShell cmdlets for Identity Governance](https://www.powershellgallery.com/packages/Microsoft.Graph.Identity.Governance/) module version 1.16.0 or a later 1.x.x module version, or Microsoft Graph PowerShell cmdlets beta module version 2.1.x or later beta module version. This script illustrates using the Graph `beta` profile and Microsoft Graph PowerShell cmdlets module version 1.x.x.
154+
You can also create an access package in PowerShell by using the cmdlets from the [Microsoft Graph PowerShell cmdlets for Identity Governance](https://www.powershellgallery.com/packages/Microsoft.Graph.Identity.Governance/) beta module version 2.1.x or later beta module version. This script illustrates using the Graph `beta` profile and Microsoft Graph PowerShell cmdlets module version 2.4.0.
155155

156-
First, retrieve the ID of the catalog (and of the resources and their roles in that catalog) that you want to include in the access package. Use a script similar to the following example:
156+
First, retrieve the ID of the catalog (and of the resource and their roles in that catalog) that you want to include in the access package. Use a script similar to the following example:
157157

158158
```powershell
159159
Connect-MgGraph -Scopes "EntitlementManagement.ReadWrite.All"
160-
Select-MgProfile -Name "beta"
161-
$catalog = Get-MgEntitlementManagementAccessPackageCatalog -Filter "displayName eq 'Marketing'"
162160
163-
$rsc = Get-MgEntitlementManagementAccessPackageCatalogAccessPackageResource -AccessPackageCatalogId $catalog.Id -Filter "resourceType eq 'Application'" -ExpandProperty "accessPackageResourceScopes"
164-
$filt = "(originSystem eq 'AadApplication' and accessPackageResource/id eq '" + $rsc[0].Id + "')"
165-
$rr = Get-MgEntitlementManagementAccessPackageCatalogAccessPackageResourceRole -AccessPackageCatalogId $catalog.Id -Filter $filt -ExpandProperty "accessPackageResource"
161+
$catalog = Get-MgBetaEntitlementManagementAccessPackageCatalog -Filter "displayName eq 'Marketing'"
162+
163+
$rsc = Get-MgBetaEntitlementManagementAccessPackageCatalogAccessPackageResource -AccessPackageCatalogId $catalog.Id -Filter "resourceType eq 'Application'" -ExpandProperty "accessPackageResourceScopes"
164+
$filt = "(originSystem eq 'AadApplication' and accessPackageResource/id eq '" + $rsc.Id + "')"
165+
$rr = Get-MgBetaEntitlementManagementAccessPackageCatalogAccessPackageResourceRole -AccessPackageCatalogId $catalog.Id -Filter $filt -ExpandProperty "accessPackageResource"
166166
```
167167

168168
Then, create the access package:
@@ -174,10 +174,10 @@ $params = @{
174174
Description = "outside sales representatives"
175175
}
176176
177-
$ap = New-MgEntitlementManagementAccessPackage -BodyParameter $params
177+
$ap = New-MgBetaEntitlementManagementAccessPackage -BodyParameter $params
178178
```
179179

180-
After you create the access package, assign the resource roles to it. For example, if you want to include the second resource role of the first resource returned earlier as a resource role of the new access package, you can use a script similar to this one:
180+
After you create the access package, assign the resource roles to it. For example, if you want to include the second resource role of the resource returned earlier as a resource role of the new access package, you can use a script similar to this one:
181181

182182
```powershell
183183
$rparams = @{
@@ -186,18 +186,18 @@ $rparams = @{
186186
DisplayName = $rr[2].DisplayName
187187
OriginSystem = $rr[2].OriginSystem
188188
AccessPackageResource = @{
189-
Id = $rsc[0].Id
190-
ResourceType = $rsc[0].ResourceType
191-
OriginId = $rsc[0].OriginId
192-
OriginSystem = $rsc[0].OriginSystem
189+
Id = $rsc.Id
190+
ResourceType = $rsc.ResourceType
191+
OriginId = $rsc.OriginId
192+
OriginSystem = $rsc.OriginSystem
193193
}
194194
}
195195
AccessPackageResourceScope = @{
196-
OriginId = $rsc[0].OriginId
197-
OriginSystem = $rsc[0].OriginSystem
196+
OriginId = $rsc.OriginId
197+
OriginSystem = $rsc.OriginSystem
198198
}
199199
}
200-
New-MgEntitlementManagementAccessPackageResourceRoleScope -AccessPackageId $ap.Id -BodyParameter $rparams
200+
New-MgBetaEntitlementManagementAccessPackageResourceRoleScope -AccessPackageId $ap.Id -BodyParameter $rparams
201201
```
202202

203203
Finally, create the policies. In this policy, only the administrator can assign access, and there are no access reviews. For more examples, see [Create an assignment policy through PowerShell](entitlement-management-access-package-request-policy.md#create-an-access-package-assignment-policy-through-powershell) and [Create an accessPackageAssignmentPolicy](/graph/api/entitlementmanagement-post-assignmentpolicies?tabs=http&view=graph-rest-beta&preserve-view=true).

0 commit comments

Comments
 (0)