> 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/devolutions-server-powershell/run-as-custom-pam-providers-powershell-scripts-with-execution-context.md).

# Run as custom PAM providers PowerShell scripts with execution context

The ***Run as*** option lets you run custom PAM provider scripts within different contexts and runs the scheduler to do so. This can be done on a local or a remote machine, making it useful to find out what the script is trying to accomplish, whether it is completing certain actions or accessing certain files.

{% hint style="info" %}
Devolutions Server already includes Azure Key Vault and Windows Accounts [custom scripts](https://docs.devolutions.net/pam/server/getting-started/anyidentity/create-anyidentity-pam-provider-dvls/#import-an-anyidentity-template) templates.
{% endhint %}

### Run As PowerShell script in various contexts

1. In Devolutions Server, go to ***Administration*** – ***Privileged Access*** – ***Providers***.
2. Click on ***Add***.
3. Click on the ***Custom*** tab.
4. Select a PAM provider then click ***Continue***.
5. Click on the ***Run as*** tab.

   <figure><img src="https://cdnweb.devolutions.net/docs/docs_en_kb_KB0151.png" alt=""><figcaption></figcaption></figure>
6. In the ***Credential*** drop-down list, select either;

   * Default: Runs the script with the current scheduler configuration.
   * Custom: Runs the script within a specified ***Username***, ***Password*** and ***Host name***.

   <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>It is advised to pick or create a user with less permissions to test a script.</p></div>
7. Click ***Save*** to close this window and save the changes.

#### Check for trusted hosts

If ***Run as*** is not pointing to a trusted host, the configuration will not work.

Here is the command line to fetch trusted hosts: `Get-Item "WSMan:localhost\Client\TrustedHosts"`

Here is the command line to update the local machine's trusted hosts with a certain value: `Set-Item 'WSMan:localhost\Client\TrustedHosts' -Value '*' -Force`

{% hint style="warning" %}
Make certain to replace the `*` in the command above. If left as is the `*` acts as a wildcard, which would make every remote host become trusted.
{% endhint %}

{% hint style="info" %}
Read the topic on [trusted hosts](https://docs.devolutions.net/server/kb/how-to-articles/winrm-trustedhostslist/) for more information.
{% endhint %}


---

# 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 dynamically by asking a question.

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

```
GET https://docs.devolutions.net/powershell/devolutions-server-powershell/run-as-custom-pam-providers-powershell-scripts-with-execution-context.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.
