Reputation: 43
We have a scenario wherein we are trying to fetch the attached disk VM wise and the respective the total space assigned to these disks. Is there any command or script to get the detail?
I have used the command Get-AzureDisk
to get the output but it does not display all the VMs that I have in my list. Not sure why, any solution?
Upvotes: 1
Views: 618
Reputation: 13974
I tried using PS file to load the subscription
We can use this script to login azure account:
$password = ConvertTo-SecureString "your password" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($accountName, $password)
Login-AzureRmAccount -Credential $credential
About disks, we can use powershell to get OS disk size and data disk size:
data disk:
PS C:\Users> $a = (get-azurermvm -ResourceGroupName vm -Name jasonvm)
PS C:\Users> $a.StorageProfile.DataDisks
Name : jasonvm-20170428-161615
DiskSizeGB : 20
Lun : 0
Caching : None
CreateOption : Empty
SourceImage :
VirtualHardDisk :
About OS disk, if you have not resize OS disk, Linux and windows OS disk are 30 GB (if your windows VM created before 2017.2, the OS disk size is 127GB, Linux is 30GB): If you have resize the OS disk, we can use this script to get the size:
PS C:\Users> $vm = get-azurermvm -ResourceGroupName vm -Name jasonvm
PS C:\Users> $vm.StorageProfile.OsDisk.DiskSizeGB
100
If can't return any result, it means your OS size set by default.
Upvotes: 1