Skip to content

Get-KeyVaultSecret

Azure: Gets Key Vault secrets

param(
	[Parameter(Mandatory = $true)]
	[string]$VaultName,

	[Parameter(Mandatory = $false)]
	[string]$Name
)

try {
	Import-Module Az.KeyVault -ErrorAction Stop

	[hashtable]$cmdArgs = @{ 'VaultName' = $VaultName; 'ErrorAction' = 'Stop' }
	if ($Name) { $cmdArgs.Add('Name', $Name) }

	$secrets = Get-AzKeyVaultSecret @cmdArgs
	Write-Output $secrets
} catch {
	Write-Error $_
	exit 1
}

The name of the Key Vault.

The name of the secret (optional).

An interactive directory of PowerShell scripts.