Skip to content

Commit caafde3

Browse files
committed
force PSh to return array
1 parent 055205e commit caafde3

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ You can perform this query in PowerShell with the `Get-MgEntitlementManagementAs
7070
```powershell
7171
Connect-MgGraph -Scopes "EntitlementManagement.Read.All"
7272
$accesspackage = Get-MgEntitlementManagementAccessPackage -Filter "displayName eq 'Marketing Campaign'"
73-
$assignments = Get-MgEntitlementManagementAssignment -AccessPackageId $accesspackage.Id -ExpandProperty target -All -ErrorAction Stop
73+
$assignments = @(Get-MgEntitlementManagementAssignment -AccessPackageId $accesspackage.Id -ExpandProperty target -All -ErrorAction Stop)
7474
$assignments | ft Id,state,{$_.Target.id},{$_.Target.displayName}
7575
```
7676

@@ -181,7 +181,7 @@ For example, if you want to ensure all the users who are currently members of a
181181

182182
```powershell
183183
Connect-MgGraph -Scopes "EntitlementManagement.ReadWrite.All,Directory.Read.All"
184-
$members = Get-MgGroupMember -GroupId "a34abd69-6bf8-4abd-ab6b-78218b77dc15" -All
184+
$members = @(Get-MgGroupMember -GroupId "a34abd69-6bf8-4abd-ab6b-78218b77dc15" -All)
185185
186186
$accesspackage = Get-MgEntitlementManagementAccessPackage -Filter "displayname eq 'Marketing Campaign'" -ExpandProperty "assignmentPolicies"
187187
$policy = $accesspackage.AssignmentPolicies[0]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ $ap_w_id = "29be137f-b006-426c-b46a-0df3d4e25ccd"
182182
$ap_e_id = "cce10272-68d8-4482-8ba3-a5965c86cfe5"
183183
$apa_w_filter = "accessPackage/id eq '" + $ap_w_id + "' and state eq 'Delivered'"
184184
$apa_e_filter = "accessPackage/id eq '" + $ap_e_id + "' and state eq 'Delivered'"
185-
$apa_w = Get-MgEntitlementManagementAssignment -Filter $apa_w_filter -ExpandProperty target -All
186-
$apa_e = Get-MgEntitlementManagementAssignment -Filter $apa_e_filter -ExpandProperty target -All
185+
$apa_w = @(Get-MgEntitlementManagementAssignment -Filter $apa_w_filter -ExpandProperty target -All)
186+
$apa_e = @(Get-MgEntitlementManagementAssignment -Filter $apa_e_filter -ExpandProperty target -All)
187187
$htt = @{}; foreach ($e in $apa_e) { if ($null -ne $e.Target -and $null -ne $e.Target.Id) {$htt[$e.Target.Id] = $e} }
188188
foreach ($w in $apa_w) { if ($null -ne $w.Target -and $null -ne $w.Target.Id -and $htt.ContainsKey($w.Target.Id)) { write-output $w.Target.Email } }
189189
```

articles/active-directory/governance/identity-governance-automation.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,12 @@ $TenantId = Get-AutomationVariable -Name 'TenantId'
171171
$Thumbprint = Get-AutomationVariable -Name 'Thumbprint'
172172
$auth = Connect-MgGraph -clientId $ClientId -tenantid $TenantId -certificatethumbprint $Thumbprint
173173
Import-Module Microsoft.Graph.Identity.Governance
174-
$ap = Get-MgEntitlementManagementAccessPackage -All -ErrorAction Stop
175-
$ap | Select-Object -Property Id,DisplayName | ConvertTo-Json
174+
$ap = @(Get-MgEntitlementManagementAccessPackage -All -ErrorAction Stop)
175+
if ($null -eq $ap -or $ap.Count -eq 0) {
176+
ConvertTo-Json @()
177+
} else {
178+
$ap | Select-Object -Property Id,DisplayName | ConvertTo-Json -AsArray
179+
}
176180
```
177181

178182
2. Select **Test pane**, and select **Start**. Wait a few seconds for the Azure Automation processing of your runbook script to complete.

0 commit comments

Comments
 (0)