Skip to content

Instantly share code, notes, and snippets.

@stopthatastronaut
Last active July 18, 2025 12:05
Show Gist options
  • Save stopthatastronaut/840dd0cf9e297f2a76c96f260aa4de74 to your computer and use it in GitHub Desktop.
Save stopthatastronaut/840dd0cf9e297f2a76c96f260aa4de74 to your computer and use it in GitHub Desktop.
Import your local powershell env from a Dashlane Secure Note
Function Import-Environment {
[CmdletBinding()]
param(
$SecureNote = 'EnvironmentVariables',
[switch]$KeepUnlocked
)
# setup to load secrets
Import-Module powershell-yaml
dcli sync
$yml = dcli note $SecureNote
$var = $yml | ConvertFrom-Yaml
$var.EnvironmentVars.GetEnumerator() | ForEach-Object {
Set-Item "Env:/$($_.Key)" -Value $_.Value
}
if(-not $KeepUnlocked) {
dcli lock
} else {
Write-Warning "KeepUnlocked was specified. Password manager unlocked."
}
}
Import-Environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment