I wrote this script to output a table formatted file:
$VMs = Get-AzureRmVM
$vmOutput = $VMs | ForEach-Object {
[PSCustomObject]@{
"VM Name" = $_.Name
"VM Type" = $_.StorageProfile.osDisk.osType
"VM Profile" = $_.HardwareProfile.VmSize
"VM OS Disk Size" = $_.StorageProfile.OsDisk.DiskSizeGB
"VM Data Disk Size" = ($_.StorageProfile.DataDisks.DiskSizeGB) -join ','
}
}
$vmOutput | export-csv C:\***\data.csv -delimiter ";" -force -notypeinformation
Is there any possibility to sum "VM Data Disk Size" for each object? I used -join parameter only because data wasn't properly exported, because of more than one data disk per vm.