$headers = @{ 'Authorization' = "Bearer $accesstoken" 'Content-Type' = 'application/json' } $requesturi = "https://management.azure.com/subscriptions/$subscriptionid/providers/Microsoft.Compute/virtualMachines?api-version=2024-07-01" $ret = (Invoke-RestMethod -Uri $requesturi -Headers $headers -Method Get) $ret $ret | ConvertTo-Json -Depth 10 |Set-Content "~\vmlist.json" notepad $env:USERPROFILE\vmlist.json