diff --git a/docs/identity/managed-identities-azure-resources/how-to-use-vm-token.md b/docs/identity/managed-identities-azure-resources/how-to-use-vm-token.md index 4aed58d023b..388007446b0 100644 --- a/docs/identity/managed-identities-azure-resources/how-to-use-vm-token.md +++ b/docs/identity/managed-identities-azure-resources/how-to-use-vm-token.md @@ -291,23 +291,22 @@ The following example demonstrates how to use the managed identities for Azure r 2. Use the access token to call an Azure Resource Manager REST API and get information about the VM. Be sure to substitute your subscription ID, resource group name, and virtual machine name for ``, ``, and ``, respectively. ```azurepowershell -Invoke-RestMeth -Method GET -Uri 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F' -Headers @{Metadata="true"} +Invoke-RestMethod -Method GET -Uri 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F' -Headers @{Metadata="true"} ``` Example of how to parse the access token from the response: ```azurepowershell # Get an access token for managed identities for Azure resources $resource = 'https://management.azure.com' -$response = Invoke-RestMeth -Method GET ` - -Uri 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=$resource' ` +$response = Invoke-RestMethod -Method GET ` + -Uri "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=$resource" ` -Headers @{ Metadata="true" } -$content = $response.Content | ConvertFrom-Json -$accessToken = $content.access_token +$accessToken = $response.access_token Write-Host "Access token using a User-Assigned Managed Identity is $accessToken" # Use the access token to get resource information for the VM $secureToken = $accessToken | ConvertTo-SecureString -AsPlainText -$vmInfoRest = Invoke-RestMeth -Method GET ` +$vmInfoRest = Invoke-RestMethod -Method GET ` -Uri 'https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Compute/virtualMachines/?api-version=2017-12-01' ` -ContentType 'application/json' ` -Authentication Bearer `