Powershell – Storage Spaces Get-VirtualDisk -FriendlyName vDisk | Get-PhysicalDisk

powershellstorage-spaceswindows-server-2016

I am using Server 2016 storage spaces.

I have created a virtual disk in a storage pool via powershell (FriendlyName "vDisk")
I have also created another virtual disk via the gui (FriendlyName "test").

The virtual disk that I have created shows which physical disks it uses, but the one I have created with powershell does not.. why is that ?

Get-VirtualDisk  -FriendlyName vDisk | Get-PhysicalDisk

-shows nothing

Get-VirtualDisk  -FriendlyName test | Get-PhysicalDisk

-shows list of hard drives

I compared the virtual disks, both are initialized and other setting are not different. I updated the host cache, storageprovider cache and I updated the "vDisk"..

Does somebody know why a virtual disk, which has been created via

New-VirtualDisk -FriendlyName vDisk -ResiliencySettingName Mirror -PhysicalDisksToUse $disks -StoragePoolFriendlyName Pool -UseMaximumSize

doesn't show its physical drives, as the gui-created one ?

Update: I noticed, when I don't use the parameter "-PhysicalDisksToUse" with New-VirtualDisk then the physical disks can be displayed by

Get-VirtualDisk -FriendlyName vDisk | Get-PhysicalDisk

Best Answer

I have found my own mistake.

I initially used a variable to define whichs physical disk should be used for my virtualdisks.

I wanted to use only HDDs, so

$disks = Get-PhysicalDisk | ? {$_.MediaType -eq 'HDD'}

Then I wanted to create my virtual disk.

New-VirtualDisk -FriendlyName vDisk -ResiliencySettingName Mirror -StoragePoolFriendlyName Pool -Size 930GB -PhysicalDisksToUse $disks

I did not think about my first command, Get-PhysicalDisk does return the system drive too - and not only the disks in the pool !

Somehow the cmdlet "New-VirtualDisk" was able to create a virtual disk with the system drive in $disks-array.. - I don't think that should be possible

I should have defined my variable as

$disks = Get-StoragePool -FriendlyName Pool | Get-PhysicalDisk | ? {$_.MediaType -eq 'HDD'}