I am trying to export VMs list from Azure Update management using Azure Rest API. Below is my code. $url = "https://management.azure.com/subscriptions/$($SubscriptionId)/resourceGroups/$($resourceGroup)/providers/Microsoft.Automation/automationAccounts/$($automationAccount)/softwareUpdateConfigurations/$($UpdateScheduleName)?api-version=" + $apiversion $RestMethod = (Invoke-RestMethod -Uri $url -Headers $headerParams -Method Get) $NonAzComputerList = ($RestMethod).Properties.updateConfiguration.nonAzureComputerNames $NonAzComputerList.GetType().FullName Write-Output $NonAzComputerList $NonAzComputerList | Export-Csv "VMList.csv" -NoTypeInformation
On Console, I do get the output correctly with VM names, but in CSV file, I get some random numbers instead of VM names.
I tried convertfrom-json as well but it shows error as "convertfrom-json : Invalid JSON primitive".
The GetType shows System.Object[]
In Console, I am getting correct VM names. OurVM01 OurVM022 OurVM0113 OurVM034
In CSV file, I am getting numbers (equal to number of characters in VM names). List 07 08 09 08