> 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/scripting/scripting-for-osd/set-secret-or-get-secret.md).

# Set-Secret | Get-Secret

In DeployR 1.2 the options to create secrets on the server and use in a task sequence was introduced.  Currently a couple of native steps in DeployR use this method which can be used as samples as well.

* Enable Administrator account \[EnableAdmin.ps1]
* Enable Bitlocker \[EnableBitlcoker.ps1]

Get-Secret and Set-Secret are part of the Microsoft.PowerShell.SecretManagement module, which we ship with DeployR to ensure it doesn't need to be fetched from the internet from a client that doesn't have internet access.

It provides authenticated access to the values (using the standard DeployR auth mechanisms).  Values are stored in the server database and can then be retrieved by a client, used, and discarded without ever needing to write them to disk, which makes it impossible to retrieve post OSD and much more secure than embedding credentials in a script or even setting it in a task sequence variable.

### Create Secret

Connect to the DeployR server via the PS Module, and use the Set-Secret command

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

In that example the secret named **DellBIOSPassword** was set to **P\@ssw0rd**

{% hint style="info" %}
It's best to always use -Vault DeployR in the command line incase other vaults are ever created on the server.
{% endhint %}

### Retrieve Secret

Testing from Windows, connect to the DeployR server via PowerShell, and run the Get-Secret command

```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="/files/8FIsMQELGlzNDqHMGC4s" 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 dynamically by asking a question.

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

```
GET https://documentation.2pintsoftware.com/deployr/scripting/scripting-for-osd/set-secret-or-get-secret.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
