> For the complete documentation index, see [llms.txt](https://documentation.2pintsoftware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.2pintsoftware.com/deployr/automation-and-powershell/scripting-for-osd/set-secret-or-get-secret.md).

# Set-Secret | Get-Secret

DeployR 1.2 introduced the ability to create secrets on the server and use them in task sequences. Several built-in DeployR steps use this method and can serve as examples.

* Enable Administrator account \[EnableAdmin.ps1]
* Enable BitLocker \[EnableBitLocker.ps1]

Get-Secret and Set-Secret are part of the Microsoft.PowerShell.SecretManagement module, which ships with DeployR so that clients without internet access do not need to download it.

The module provides authenticated access to secret values using the standard DeployR authentication mechanisms. Values are stored in the server database and retrieved by the client when needed. They can then be used and discarded without being written to disk, making them unavailable for retrieval after OSD and more secure than embedding credentials in a script or task sequence variable.

{% hint style="info" %}
Starting with DeployR 1.4, only users with write access can create, change, or delete secrets.
{% endhint %}

### Create Secret

Connect to the DeployR server using the PowerShell module, then run `Set-Secret`:

```powershell
Set-Secret -Name "DellBIOSPassword" -Secret "P@ssw0rd" -Vault DeployR
```

This example creates a secret named **DellBIOSPassword** with the value **P\@ssw0rd**.

{% hint style="info" %}
Specify `-Vault DeployR` in the command to avoid ambiguity if other vaults are added to the server.
{% endhint %}

### Retrieve Secret

To test from Windows, connect to the DeployR server using PowerShell and run `Get-Secret`:

```powershell
Get-Secret -Name "DellBIOSPassword" | ConvertFrom-SecureString  -AsPlainText
```

When running in a task sequence, adding something similar to this in your PowerShell script will pull the secret into a variable.

```powershell
try {
    $SecretBIOSPassword = Get-Secret -Vault DeployR -Name "DellBIOSPassword" | ConvertFrom-SecureString -AsPlainText -ErrorAction Stop
}
catch {
    Write-Warning "DellBIOSPassword secret not found. Checking task sequence environment variable fallback."
}
```

### Console Example:

<figure><img src="https://content.gitbook.com/content/8m0VARX9oyZ2zXWCdPgr/blobs/sczHHTKs7iLYOTFcQY5c/image.png" alt=""><figcaption></figcaption></figure>


---

# 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://documentation.2pintsoftware.com/deployr/automation-and-powershell/scripting-for-osd/set-secret-or-get-secret.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.
