Forum Discussion
zmmj123
May 12, 2021Copper Contributor
Check the hyper-v vm's Maximum disk size
Hi all, In vm's setup, in SCSI controller, in virtual hard disk, and click "inspect" botten, I can see the "Maximum disk size". Now I want to use powershell commandlet to check this value, please help to check which command can get this value. Many thanks.
6 Replies
Sort By
- SteveMacNZIron Contributor
Get-VHD is the command you want to use specifying the path to the VHD. ensure that you use administrative PowerShell console as running as standard account is unlikely to have the correct permissions within Hyper-V.
FileSize will give you the current size of the VHD for dynamic disks and Size gives you the configured maximum VHD size - you will need to convert the values into GB. see example below
Get-VHD -Path "C:\Hyper-V\Virtual Hard Disks\abc.vhdx" | Select-Object @{Name="FileSizeGB";Expression={$_.FileSize/1GB}}, @{Name="MaxSizeGB";Expression={$_.Size/1GB}}
- SteveMacNZIron Contributor
You can also expand this out to list for all VHDX files under a given location as well using this script, which will give you the VHDName FileSize and MaxSize
$vhds = Get-ChildItem -path C:\Hyper-V\ -filter *.vhdx -Recurse | Select-Object Name, Directory $results =@() ForEach ($vhd in $vhds){ $vpath = "$($vhd.Directory)" + "\" + "$($VHD.Name)" $results += Get-VHD -Path $vpath | Select-Object @{Name="VHDName";Expression={$_.Path.split("\")[-1]}} , @{Name="FileSize_GB";Expression={$_.FileSize/1GB}} , @{Name="MaxSizeGB";Expression={$_.Size/1GB}} } $results | Format-Table
- zmmj123Copper ContributorMany thanks for your help, I can use powershell comlet get the value now.
- yiuyuxx235Copper Contributornice
- SchnittlauchSteel ContributorNever have seen such an important comment yiuyuxx235 xD