Creating a Storage Space in Windows 10 with Powershell

I’m not sure if this is due to system in question being in the insider fast ring (Build 19041 version 10.0.19041), however when trying to create a storage space via the GUI I got the following error:

Can't prepare drives

Close all applications that are accessing the drive and then try again.

‪The parameter is incorrect.
 (0x00000057)‬

You have to make sure the disks are clear of partitions otherwise they will not even appear in the create storage pool wizard. In this case however disks were clear of partitions and good to go but for some reason the GUI didn’t like them. Creating the pool and assigning disks via powershell worked without issue, go figure. The following is specific to my environment but you can get the gist and modify it for your own setup without too much trouble. To start open an elevated powershell prompt and run:

$PhysicalDisks = (Get-PhysicalDisk -CanPool $True)

This gets a list of disks. You can see the contents of the object by executing $PhysicalDisks. For me this looked like:

Great given that these are the four disks I’m interested in! Note, if you see disks you are not interested in, then go no further as you could lose data. In my case I’m happy so to add these disks to a storage space use:

New-StoragePool -FriendlyName SS -StorageSubsystemFriendlyName "Windows Storage*" -PhysicalDisks $PhysicalDisks

This resulted in:

Looking good. Now to create a virtual disk from the newly created storage space:

New-VirtualDisk -StoragePoolFriendlyName SS -FriendlyName SS1 -ResiliencySettingName Mirror -UseMaximumSize

Resulted in:

For this task I was looking for a mirror rather than parity, however you can customise ResiliencySettingName to your own tastes. Nearly there, now to create a filesystem:

Get-VirtualDisk -FriendlyName SS1 | Get-Disk | Initialize-Disk -Passthru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem ntfs

Obviously you can change any of the Cmdlet flags like filesystem or assigned drive letter. I’m not really sure why the GUI didn’t work, perhaps if it was related to the insider ring however powershell seemed to work well. Powershell for the win.