Skip to content

Instantly share code, notes, and snippets.

@kpatnayakuni
Last active February 4, 2020 12:04
Show Gist options
  • Save kpatnayakuni/a2df672d5fad5f91c519fb55bcb28541 to your computer and use it in GitHub Desktop.
Save kpatnayakuni/a2df672d5fad5f91c519fb55bcb28541 to your computer and use it in GitHub Desktop.
## On the NEW VM in which User Assigned Managed Identity enabled
# Enter-PSSession -ComputerName $vmPIP -Credential $credential
# Install NuGet package provider where Az module is availble
Install-PackageProvider -Name NuGet -Force
# Install the Az module
Install-Module -Name Az -Force
# Login to Azure with managed identity
Login-AzAccount -Identity
# Get the secret from the Key Vault
$kvName = 'testakv99'
$keyName = 'sysadmin'
$Secret = Get-AzKeyVaultSecret -VaultName $kvName -Name $keyName | % SecretValueText
# You can use this secret in your code, since it is a demo I am writing it to screen
Write-Host "The password is: $Secret"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment