--- title: "Quickstart: PowerShell" slug: "quickstart-powershell" updated: 2026-09-10T17:41:52Z published: 2026-09-10T17:41:52Z canonical: "docs.redcanary.com/quickstart-powershell" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.redcanary.com/llms.txt > Use this file to discover all available pages before exploring further. # PowerShell Example Follow these necessary steps to write and run a simple PowerShell script that queries the Zscaler MDR API. ## Prerequisites Before running any code, ensure you have the following: - [Your API token](/doc/docs/red-canary-rest-api#generating-an-api-authentication-token) - [The latest recommended version of PowerShell](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.2) ## Create your PowerShell script Create a PowerShell script called `example.ps1`, which fetches a list of endpoints from a subdomain. 1. In your working directory, create a new file called `example.ps1`, and then copy the following code into it. ```plaintext # Create a GET request and save the response. $response = Invoke-WebRequest https://.my.redcanary.co/openapi/v3/endpoints ` -Headers @{'X-Api-Key' = ''} ` -Method GET # Print the body of the response. $response.Content ``` 2. In `example.ps1`, replace with the subdomain you want to query. 3. In `example.ps1`, replace with your API key. 4. Save `example.ps1`. ## Run the example Open PowerShell, and run your example. ```plaintext .\example.ps1 ``` The script should print a JSON object containing the first page of endpoints associated with the subdomain. > **Note:** You might need to change PowerShell’s execution policy to `RemoteSigned` to run your script. For more information, see [Change the execution policy](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.2#change-the-execution-policy) in the Microsoft docs. ## Customize your request with parameters You can use HTTP parameters to customize the results of your request. Visit the [Zscaler MDR API docs](https://go.my.redcanary.co/openapi/v3/docs/index.html) for a list of supported parameters for each API endpoint. ## Example: Limit the number of endpoints returned Limit the number of endpoints returned by `example.ps1` using the `per_page` parameter. 1. Open `example.ps1`, and edit the response to include the `-Body` parameter. ```plaintext $response = Invoke-WebRequest https://.my.redcanary.co/openapi/v3/endpoints ` -Headers @{'X-Api-Key' = ''} ` -Method GET ` -Body @{'per_page' = '1'} ``` This sets the number of requested endpoints to one. 2. Save `example.ps1`, and then run the example. The program should print a JSON object containing exactly one endpoint.