# Secrets Out of Scripts

A password or token written into a script travels wherever the script goes, so a script names the secret it needs and reads it from an environment variable, asks for it with Get-Credential, or fetches it from a SecretManagement vault, and stops with a clear message when it isn't there.

![Cheat sheet for the lesson Secrets Out of Scripts: A password or token written into a script travels wherever the script goes, so a script names the secret it needs and reads it from an environment variable, asks for it with Get-Credential, or fetches it from a SecretManagement vault, and stops…](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/27acbd5d866d45c3b489840c39da4765.webp)

- Category: PowerShell
- Level: Journeyman
- Tags: environment-variable, get-credential, powershell, pscredential, secret, secretmanagement, securestring
- Updated: November 10, 2026

Source: https://www.ask-codey.com/cheat-sheets/powershell-secrets-cheat-sheet
