Create VHD and VHDX Virtual Hard Disks GUI and Powershell
VHD
Older format introduced with Microsoft Virtual PC.
Limited to a maximum size of 2 TB.
Less resilient to data corruption.
Does not support dynamic resizing well.
Compatible with older Windows operating systems (Windows 7, Windows Server 2008 R2, etc.).
VHDX
Newer format introduced with Windows Server 2012 and later.
Supports sizes up to 64 TB.
Better resilience to data corruption and power failures.
Supports dynamic resizing and storage efficiency.
Includes metadata enhancements and improved alignment for modern disks.
Requires Windows 8/Server 2012 or later for compatibility.
When to choose:
Use VHDX if you're running modern Windows versions (Windows 11, Windows 10, Windows Server 2012+), require better performance, reliability, and flexibility.
Use VHD if backward compatibility with older systems is necessary.
-----
New-VHD -Path "C:\VMs\myVirtualDisk.vhdx" -SizeBytes 20GB -Dynamic
Mount-VHD -Path "C:\VMs\myVirtualDisk.vhdx"
# Get the newly mounted disk
$disk = Get-Disk | Where-Object PartitionStyle -Eq 'RAW'
# Initialize disk (use GPT or MBR)
Initialize-Disk -Number $disk.Number -PartitionStyle GPT
# Create a new partition that uses the maximum available space and assign a drive letter
New-Partition -DiskNumber $disk.Number -UseMaximumSize -AssignDriveLetter | Format-Volume -FileSystem NTFS -NewFileSystemLabel "VHD_Drive"
Dismount-VHD -Path "C:\VMs\myVirtualDisk.vhdx"
----