From 6b4590ed5cb45bed2a5854eb769c747d1680aa4a Mon Sep 17 00:00:00 2001 From: Jesper Fajers Date: Wed, 24 Apr 2024 19:34:03 +0000 Subject: [PATCH] Update --- .../functions/Get-AzOpsResourceDefinition.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/internal/functions/Get-AzOpsResourceDefinition.ps1 b/src/internal/functions/Get-AzOpsResourceDefinition.ps1 index a99d02c0..e206b20f 100644 --- a/src/internal/functions/Get-AzOpsResourceDefinition.ps1 +++ b/src/internal/functions/Get-AzOpsResourceDefinition.ps1 @@ -232,12 +232,15 @@ } } else { - if ($SubscriptionsToIncludeResourceGroups -ne '*') { - $subscriptionsToIncludeResourceGroups = $subscriptions | Where-Object { $_.Id -in $SubscriptionsToIncludeResourceGroups } - } $query = "resourcecontainers | where type == 'microsoft.resources/subscriptions/resourcegroups' | where managedBy == '' | order by ['id'] asc" - if ($subscriptionsToIncludeResourceGroups) { - $resourceGroups = Search-AzOpsAzGraph -Subscription $subscriptionsToIncludeResourceGroups -Query $query -ErrorAction Stop + if ($SubscriptionsToIncludeResourceGroups -ne '*') { + $newSubscriptionsToIncludeResourceGroups = $subscriptions | Where-Object { $_.Id -in $SubscriptionsToIncludeResourceGroups } + if ($newSubscriptionsToIncludeResourceGroups) { + $resourceGroups = Search-AzOpsAzGraph -Subscription $newSubscriptionsToIncludeResourceGroups -Query $query -ErrorAction Stop + } + else { + Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsResourceDefinition.Subscription.NotFound' -Target $ScopeObject + } } else { $resourceGroups = Search-AzOpsAzGraph -Subscription $subscriptions -Query $query -ErrorAction Stop