fix: restore .value access when using -AllPages on group queries
Invoke-GraphRequest with -AllPages returns the full response object with accumulated items in .value, not a flat array.
This commit is contained in:
@@ -279,7 +279,7 @@ if($Mode -eq "Backup")
|
||||
Write-Host "`nLoading groups for backup resolution..." -ForegroundColor Cyan
|
||||
$backupGroupsResponse = Invoke-GraphRequest "/groups?`$select=id,displayName&`$orderby=displayName" -AllPages
|
||||
$backupGroups = @{}
|
||||
foreach($g in $backupGroupsResponse)
|
||||
foreach($g in $backupGroupsResponse.value)
|
||||
{
|
||||
$backupGroups[$g.id] = $g.displayName
|
||||
}
|
||||
@@ -383,7 +383,7 @@ elseif($Mode -eq "Restore")
|
||||
# Resolve group names to IDs in current tenant if needed
|
||||
Write-Host "`nLoading current tenant groups for name resolution..." -ForegroundColor Cyan
|
||||
$currentGroupsResponse = Invoke-GraphRequest "/groups?`$select=id,displayName&`$orderby=displayName" -AllPages
|
||||
$currentGroups = $currentGroupsResponse
|
||||
$currentGroups = $currentGroupsResponse.value
|
||||
|
||||
$success = 0
|
||||
$skipped = 0
|
||||
|
||||
Reference in New Issue
Block a user