# Export-CSV Download

```powershell
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'
} -ShowLoading
```

This sample collects the first 5 processes and outputs them to a temporary CSV using Export-CSV and then uses `Start-UDDownload` to send the data to the end user.&#x20;

Note that the CSV is saved to the server using a temporary file and then read into memory using `Get-Content`. That content is then downloaded via the end user's browser.&#x20;

`-ShowLoading` is used on the button to display feedback to the user while the download is prepared.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.powershelluniversal.com/v4-beta/samples/apps/export-csv-download.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
