Functions/Data/Copy-ReportToFiles.ps1
Function Copy-ReportToFiles { [CmdletBinding()] Param ( # Data to Convert and output [Parameter(Mandatory=$true)] [array] $Data, # Path to output files to [Parameter(Mandatory=$true)] [String] $Path, # Name to use for files [Parameter(Mandatory=$true)] [String] $Name, # ReportTypes [Parameter(mandatory=$false)] [ValidateSet("JSON","CSV","XLSX")] [String[]] $ReportTypes = ("JSON","CSV","XLSX") ) # Switch on ReportTypes Requested switch ($ReportTypes) { "JSON" {$DATA | Export-JSON -Path "$Path\$Name.json" -Depth 10} "CSV" {$DATA | Export-Csv -Path "$Path\$Name.csv" -NoTypeInformation -Encoding UTF8} "XLSX" {$DATA | Export-Excel -Path "$path\$Name.xlsx"} } } |