Export-CSV Download
This sample shows how to generate data with Export-CSV and send it to the user via a download.
New-UDButton -Text 'Generate Report' -OnClick {
$TempFile = New-TemporaryFile
Get-Process | Select-Object -First 5 | Export-CSV -Path $TempFile
$Csv = Get-Content -Path $TempFile -Raw
Remove-Item $TempFile
Start-UDDownload -StringData $Csv -FileName 'processes.csv' -ContentType 'text/csv'
} -ShowLoadingLast updated
Was this helpful?