Skip to content

Commit

Permalink
Export-AzPolicyResources adds CSV file with ownerships (#467)
Browse files Browse the repository at this point in the history
  • Loading branch information
techlake authored Jan 27, 2024
1 parent 6ca2577 commit ce51329
Show file tree
Hide file tree
Showing 3 changed files with 276 additions and 143 deletions.
19 changes: 17 additions & 2 deletions Scripts/Helpers/Out-PolicyExemptions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function Out-PolicyExemptions {
$null = New-Item $outputPath -Force -ItemType directory
}

#region Transformations

$policyDefinitionReferenceIdsTransform = @{
label = "policyDefinitionReferenceIds"
expression = {
Expand Down Expand Up @@ -97,10 +99,15 @@ function Out-PolicyExemptions {
}
}

#endregion Transformations

Write-Information ""
$selectedExemptions = $Exemptions.Values
$selectedExemptions = $policyExemptions.Values
$numberOfExemptions = $selectedExemptions.Count
if ($ActiveExemptionsOnly) {

#region Active Exemptions

$stem = "$outputPath/active-exemptions"
Write-Information "==================================================================================================="
Write-Information "Output $numberOfExemptions active (not expired or orphaned) Exemptions for epac environment '$pacSelector'"
Expand Down Expand Up @@ -158,10 +165,15 @@ function Out-PolicyExemptions {
$columnHeaders = "name,displayName,description,exemptionCategory,expiresOn,scope,policyAssignmentId,policyDefinitionReferenceIds,metadata,assignmentScopeValidation"
$columnHeaders | Out-File $csvFile -Force
}

}

#endregion Active Exemptions

}
else {

#region All Exemptions

$stem = "$outputPath/all-exemptions"
Write-Information "==================================================================================================="
Write-Information "Output $numberOfExemptions Exemptions (all) for epac environment '$pacSelector'"
Expand Down Expand Up @@ -225,5 +237,8 @@ function Out-PolicyExemptions {
}

}

#endregion All Exemptions

}
}
2 changes: 1 addition & 1 deletion Scripts/Operations/Build-PolicyDocumentation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ $InformationPreference = 'Continue'
$globalSettings = Get-GlobalSettings -DefinitionsRootFolder $DefinitionsRootFolder -OutputFolder $OutputFolder
$definitionsFolder = $globalSettings.policyDocumentationsFolder
$pacEnvironments = $globalSettings.pacEnvironments
$outputPath = "$($globalSettings.outputFolder)/PolicyDocumentation"
$outputPath = "$($globalSettings.outputFolder)/policy-documentation"
if (-not (Test-Path $outputPath)) {
New-Item $outputPath -Force -ItemType directory
}
Expand Down
Loading

0 comments on commit ce51329

Please sign in to comment.