Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefajers authored Aug 22, 2024
1 parent fab7443 commit ec096bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions scripts/Remove-AzOpsTestsDeployment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
foreach ($subscription in $cleanupSub) {
$null = Set-AzContext -SubscriptionId $subscription.Id
$null = Get-AzResourceLock | Remove-AzResourceLock -Force
Start-Sleep -Seconds 15
$script:resourceGroups = Get-AzResourceGroup | Where-Object {$_.ResourceGroupName -like "*-azopsrg"}
$script:roleAssignmentsCleanBase = Get-AzRoleAssignment | Where-Object {$_.Scope -ne "/"}
$script:roleAssignments = foreach ($roleAssignment in $script:roleAssignmentsCleanBase) {
Expand Down
4 changes: 2 additions & 2 deletions src/internal/functions/Remove-AzOpsDeployment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
)
if ($resourceToDelete.Type -eq 'Microsoft.Authorization/policyDefinitions') {
$dependency = @()
$query = "PolicyResources | where type == 'microsoft.authorization/policysetdefinitions' and properties.policyType == 'Custom' | project id, type, policyDefinitions = (properties.policyDefinitions) | mv-expand policyDefinitions | project id, type, policyDefinitionId = tostring(policyDefinitions.policyDefinitionId) | where policyDefinitionId == '$($resourceToDelete.PolicyDefinitionId)' | order by policyDefinitionId asc | order by id asc"
$query = "PolicyResources | where type == 'microsoft.authorization/policysetdefinitions' and properties.policyType == 'Custom' | project id, type, policyDefinitions = (properties.policyDefinitions) | mv-expand policyDefinitions | project id, type, policyDefinitionId = tostring(policyDefinitions.policyDefinitionId) | where policyDefinitionId == '$($resourceToDelete.Id)' | order by policyDefinitionId asc | order by id asc"
$depPolicySetDefinition = Search-AzGraphDeletionDependency -query $query
if ($depPolicySetDefinition) {
$depPolicySetDefinition = foreach ($policySetDefinition in $depPolicySetDefinition) {
Expand All @@ -167,7 +167,7 @@
}
}
if ($dependency) {
$dependency = $dependency | Sort-Object ResourceId -Unique | Where-Object {$_.ResourceId -ne $resourceToDelete.ResourceId}
$dependency = $dependency | Sort-Object Id -Unique | Where-Object {$_.Id -ne $resourceToDelete.Id}
return $dependency
}
}
Expand Down

0 comments on commit ec096bc

Please sign in to comment.