> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/powershell-commands/invoke-psutest.md).

# Invoke-PSUTest

Run a PowerShell Universal Pester test file or folder and optionally wait for and return its results.

## SYNOPSIS

Starts a Pester test run in PowerShell Universal.

## SYNTAX

```powershell
Invoke-PSUTest -Path <String> [-Environment <String>] [-Tag <String[]>] [-ExcludeTag <String[]>] [-Test <String[]>] [-Wait] [-Timeout <Int32>] [-IncludeSuite] [<ConnectionOptions>] [<CommonParameters>]
Invoke-PSUTest -TestFile <TestFile> [-Environment <String>] [-Tag <String[]>] [-ExcludeTag <String[]>] [-Test <String[]>] [-Wait] [-Timeout <Int32>] [-IncludeSuite] [<ConnectionOptions>] [<CommonParameters>]
```

`<ConnectionOptions>`: `[-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>] [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]`.

## DESCRIPTION

Starts a Pester test run and returns a test-run record. Use tag and test-name filters to target tests. `-Wait` polls for completion; `-Timeout` defaults to 300 seconds and `0` disables the wait timeout. `-IncludeSuite` returns an object containing `TestRun` and `TestSuite` (with or without `-Wait`).

## EXAMPLES

```powershell
Invoke-PSUTest -Path '.\tests\api.tests.ps1'
Invoke-PSUTest -Path '.\tests\api.tests.ps1' -Tag Smoke -ExcludeTag Slow
Invoke-PSUTest -Path '.\tests\api.tests.ps1' -Test 'API returns 200'
Invoke-PSUTest -Path '.\tests\api.tests.ps1' -Wait -IncludeSuite
```

## PARAMETERS

| Parameter                | Description                                                                  |
| ------------------------ | ---------------------------------------------------------------------------- |
| `-Path`                  | Required test file or folder path (Path parameter set).                      |
| `-TestFile`              | Required test-file object; accepts pipeline input (TestFile parameter set).  |
| `-Environment`           | Execution environment for the test run.                                      |
| `-Tag`                   | Includes tests with these Pester tags (alias `-TagFilter`).                  |
| `-ExcludeTag`            | Excludes tests with these tags (alias `-ExcludeTagFilter`).                  |
| `-Test`                  | Pester full-name filters (aliases `-FullName`, `-FullNameFilter`, `-Tests`). |
| `-Wait`                  | Waits for completion before returning.                                       |
| `-Timeout`               | Wait timeout in seconds, default 300; `0` disables it.                       |
| `-IncludeSuite`          | Returns both test run and parsed suite.                                      |
| `-ComputerName`          | PSU Management API URL or host name (alias `-Uri`).                          |
| `-AppToken`              | Management API app token.                                                    |
| `-Credential`            | Management API credentials.                                                  |
| `-UseDefaultCredentials` | Uses current Windows credentials.                                            |
| `-Integrated`            | Uses the in-process management client.                                       |
| `-TrustCertificate`      | Ignores certificate validation errors.                                       |
| `-Cookies`               | Reuses session authentication cookies.                                       |

## OUTPUTS

`PowerShellUniversal.Models.Testing.TestRun`, or an object containing `TestRun` and `TestSuite` when `-IncludeSuite` is specified.

## PERMISSIONS

The access token requires `automation.tests/execute` to run this cmdlet remotely.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/powershell-commands/invoke-psutest.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
