From 9b578dd5ed9edef807fe4dc082724bba869991e6 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Wed, 5 Jun 2024 15:10:47 +0100 Subject: [PATCH] Add policy set definition workaround (#1659) --- src/Alz.Tools/functions/Alz.Tools.ps1 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Alz.Tools/functions/Alz.Tools.ps1 b/src/Alz.Tools/functions/Alz.Tools.ps1 index e2b3a6c514..d45212513b 100644 --- a/src/Alz.Tools/functions/Alz.Tools.ps1 +++ b/src/Alz.Tools/functions/Alz.Tools.ps1 @@ -71,6 +71,10 @@ function ProcessObjectByResourceType { } "microsoft.authorization/policysetdefinitions" { $outputObject = [PolicySetDefinition]::new($ResourceObject) + # Workaround for policySetDefinitions that only have a single policyDefinition. PowerShell tires to convert to an object in that scenario. + if($outputObject.properties.policyDefinitions.GetType().ToString() -eq "PolicySetDefinitionPropertiesPolicyDefinitions") { + $outputObject.properties.policyDefinitions = @($outputObject.properties.policyDefinitions) + } } "microsoft.authorization/roleassignments" { $outputObject = [RoleAssignment]::new($ResourceObject)