When using the .NET DiscUtils PowerShell Module, I get the following error:
Import-Module DiscUtils.psd1
New-VirtualDisk hd.vhd -Type VHD-dynamic -Size 500MB
Initialize-VirtualDisk hd.vhd -VolumeManager Bios
Initialize-VirtualDisk : Path specified is not a virtual disk
hd.vhd
is valid, and if mounted with other tools, is recognized by Windows Disk Management.
Just found the proper way:
Import-Module DiscUtils.psd1
New-VirtualDisk hd.vhd -Type VHD-dynamic -Size 500MB
New-PSDrive vhd -PSProvider virtualdisk -Root hd.vhd -ReadWrite
Initialize-VirtualDisk vhd: -VolumeManager Bios
One can subsequently partition and format the drive.
To format the first 250MB NTFS:
New-Volume vhd: -Size 250MB -Type WindowsNtfs
Format-Volume vhd:\Volume0 -Filesystem Ntfs -Label "virtdrive"