Private/Export/Export-BaselineCsv.ps1
|
function Export-BaselineCsv { <# .SYNOPSIS Exports the merged baseline (ALZ + MCSB) to CSV file. .DESCRIPTION Exports the complete baseline policy list to a CSV file named Baseline_ALZ_MCSB_Policies.csv in the specified output folder. Includes all baseline policies with their metadata: DisplayName, ID, Version, Effect, Type, and BaselineSources. .PARAMETER Baseline Array of baseline policy objects to export. .PARAMETER OutputPath Full path to the output CSV file. .EXAMPLE Export-BaselineCsv -Baseline $baseline -OutputPath "C:\Reports\baseline\Baseline_ALZ_MCSB_Policies.csv" Exports baseline to specified CSV file. .OUTPUTS None. Writes CSV file to disk. #> [CmdletBinding()] param( [Parameter(Mandatory)] [object[]]$Baseline, [Parameter(Mandatory)] [string]$OutputPath ) try { $Baseline | Sort-Object PolicyDisplayName | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8 Write-Host (" ✅ Baseline exported: {0}" -f (Split-Path $OutputPath -Leaf)) -ForegroundColor Green } catch { Write-Warning "Failed to export baseline CSV: $($_.Exception.Message)" } } |