Reputation: 991
I have been trying to create a script that can get a list of all managed disks in Azure, which includie vmname, diskname, size, OSType and resource group name and more importantly free space and available disk space remaining.
I can get the basic information using Powershell, however I can't seem to get current disk usage and free space remaining, I was hoping some guidance or point in the right direction.
$vms = Get-AzureRmVM
foreach ($vm in $vms) {
Get-AzureRmDisk | select -Property $vm.Name,Name,DiskSizeGB,OSType,ResourceGroupName
}
Thanks in advance
Upvotes: 0
Views: 4870
Reputation: 679
You also could use a Hybrid-Worker and run this Command:
Getting all local Disks (exclude the Temp-Drive D)
$Disks = get-WmiObject win32_logicaldisk `
| Where-Object -Property VolumeName -ne "Temporary Storage"
Calculate the free Space in Percent and create a PS Custom Object
$Report = @()
foreach ($Disk in $Disks) {
$myObject = [PSCustomObject]@{
Hostname = hostname
Disk = $Disk.DeviceID
FreeSpace = [math]::Round((($Disk.FreeSpace * 100) / $Disk.Size),0)
}
$Report += $myObject
}
and store the Result in a StorageAccount Table
Upvotes: 1
Reputation: 19195
Based on my knowledge, it is not possible. You could check managed disk rest APi. Azure does not provide such parameters.
So, you could not use Azure Power Shell to get managed disk usage information, you only could get total space.
One solution, you need login your VM and use command to get your disk usage.
Upvotes: 2