Before we start digging into the diskpart/Storage module functionality we need a disk to practice on. I don’t recommend using your machine’s system disk – bad things will happen.
The Hyper-V module has a New-VHD cmdlet so lets use that to create a disk to play with. The great thing about virtual disks is that you can delete then if everything goes horribly wrong.
There is a New-VirtualDisk cmdlet in the storage module but that works with storage pools. We’ll cover that later in the series.
Lets create a virtual disk:
New-VHD -Path C:\test\Test1.vhdx -Dynamic -SizeBytes 10GB
You can access the virtual disk using the path
Get-VHD -Path C:\test\Test1.vhdx
You need to mount the virtual disk before you can work with it
Get-VHD -Path C:\test\Test1.vhdx | Mount-VHD
Once mounted you can use get-Disk to identify the virtual disk
PS> Get-Disk | select Number, FriendlyName, PartitionStyle
Number FriendlyName PartitionStyle ------ ------------ -------------- 1 Msft Virtual Disk RAW 0 Samsung SSD 840 PRO Series MBR
The clue is in the friendly name and that the partition style is RAW.
Next time we’ll look at formatting and partitioning the new drive. For now we’ll just dismount the virtual disk
Dismount-VHD -DiskNumber 1