Skip to content

Instantly share code, notes, and snippets.

@gscales
Created September 19, 2019 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gscales/8fe0f836d3ad4687cff850e5ac7d20d6 to your computer and use it in GitHub Desktop.
Save gscales/8fe0f836d3ad4687cff850e5ac7d20d6 to your computer and use it in GitHub Desktop.
Key-vault example 1
$KeyVaultURL = "https://xxx.vault.azure.net/secrets/App1AuthCert/xxx99c5d054f43698f39c51f24440xxx?api-version=7.0"
$SptokenResult = Invoke-WebRequest -Uri 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fvault.azure.net' -Headers @{Metadata="true"}
$Sptoken = ConvertFrom-Json $SptokenResult.Content
$headers = @{
'Content-Type' = 'application\json'
'Authorization' = 'Bearer ' + $Sptoken.access_token
}
$Response = (Invoke-WebRequest -Uri $KeyVaultURL -Headers $headers)
$certResponse = ConvertFrom-Json $Response.Content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment