Public/Export-M365Parquet.ps1
|
function Export-M365Parquet { <# .SYNOPSIS Exports PSObjects to a Parquet file. .DESCRIPTION Thin wrapper around PSParquet's Export-Parquet with standardized defaults. Accepts pipeline input. #> [CmdletBinding()] param( [Parameter(Mandatory)] [string]$FilePath, [Parameter(Mandatory, ValueFromPipeline)] [PSCustomObject[]]$InputObject ) begin { $allObjects = [System.Collections.Generic.List[PSCustomObject]]::new() } process { foreach ($obj in $InputObject) { $allObjects.Add($obj) } } end { if ($allObjects.Count -eq 0) { Write-M365Log "No objects to export" -Level Warning return } # Ensure parent directory exists $parentDir = Split-Path -Path $FilePath -Parent if ($parentDir -and -not (Test-Path $parentDir)) { New-Item -ItemType Directory -Path $parentDir -Force | Out-Null } Write-M365Log "Exporting $($allObjects.Count) objects to $FilePath..." $allObjects | Export-Parquet -FilePath $FilePath Write-M365Log "Parquet file written: $FilePath" } } |