PowerShell SecretManagement module provides a convenient way for a user to store and retrieve secrets. The secrets are stored in SecretManagement extension vaults. An extension vault is a PowerShell module that has been registered to SecretManagement, and exports five module functions required by SecretManagement. An extension vault can store secrets locally or remotely. Extension vaults are registered to the current logged in user context, and are available only to that user.
— Microsoft.PowerShell.SecretManagement Module
Prerequisites
Install the modules
Install-Module Microsoft.PowerShell.SecretManagement, Microsoft.PowerShell.SecretStoreCreate a vault
Register-SecretVault -Name SecretStore -ModuleName Microsoft.PowerShell.SecretStore -DefaultVaultCommands
Store creds in the vault
$Creds = Get-Credential
Set-Secret -Name Client -Secret $CredsConnect with stored creds
This only works if they are not using modern authentication
Connect-ExchangeOnline -Credential (Get-Secret -Name Client)Check existing stored creds
Get-SecretInfoResources
Stop typing PowerShell credentials in demos using PowerShell SecretManagement