Windows – Removing failed drive from Storage Pool in Server 2016

powershellstoragewindows

Following instructions found here and here, I've been trying to replace a failing drive in a Windows Storage Pool. Here are the steps I'm taking after physically replacing the drive.

When running Get-PhysicalDisk, I see:

FriendlyName           SerialNumber    CanPool OperationalStatus  HealthStatus Usage            Size
------------           ------------    ------- -----------------  ------------ -----            ----
WDC WD1003FBYX-01Y7B1  WD-WCAW36848546 False   OK                 Healthy      Auto-Select 931.51 GB
WDC WD4000F9MZ-76NVPL0 WD-WCC131932768 False   OK                 Healthy      Auto-Select   3.64 TB
Generic Physical Disk                  False   Lost Communication Warning      Auto-Select   3.64 TB
WDC WD1003FBYX-01Y7B1  WD-WCAW36848210 False   OK                 Healthy      Auto-Select 931.51 GB
WDC WD4000F9MZ-76NVPL0 WD-WCC131962755 False   OK                 Healthy      Auto-Select   3.64 TB
WDC WD4000F9MZ-76NVPL0 WD-WCC131965649 False   OK                 Healthy      Auto-Select   3.64 TB
WDC WD4000F9YZ-09N20L0 WD-WCC130974882 False   OK                 Healthy      Auto-Select   3.64 TB

It's clear which one is the bad drive. So, I'm setting the bad disk to a variable,
$badDisk = Get-PhysicalDisk | Where-Object { $_.OperationalStatus -eq 'Lost Communication' }

And then retire it.

$badDisk | Set-PhysicalDisk -Usage Retired

From there, I try to remove the disk.

Remove-PhysicalDisk -PhysicalDisks $badDisk -StoragePoolName DataStore1

Remove-PhysicalDisk : The requested object could not be found.
At line:1 char:1
+ Remove-PhysicalDisk -PhysicalDisks $badDisk -StoragePoolName Data ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (PS_StorageCmdlets:ROOT/Microsoft/..._StorageCmdlets) [Remove-PhysicalDi
sk], CimException
+ FullyQualifiedErrorId : MI RESULT 6,Remove-PhysicalDisk

Oh…kay?

Add in the replacement disk first, then?

$replacementDisk = Get-PhysicalDisk –FriendlyName 'WDC WD4000F9YZ-09N20L0'

Add-PhysicalDisk –PhysicalDisks $replacementDisk –StoragePoolFriendlyName DataStore1

Add-PhysicalDisk : The requested object could not be found.
At line:1 char:1
+ Add-PhysicalDisk –PhysicalDisks $replacementDisk –StoragePoolFriendly ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (PS_StorageCmdlets:ROOT/Microsoft/..._StorageCmdlets) [Add-PhysicalDisk]
, CimException
+ FullyQualifiedErrorId : MI RESULT 6,Add-PhysicalDisk

What the hell am I doing wrong? I know I don't know Powershell as well as I'd like but… Everything here seems fairly straightforward.

Best Answer

Not sure if you solved it, but I had exactly the same issue and just found here the solution: https://social.technet.microsoft.com/Forums/en-US/a7cdd6ce-db9c-47f8-b366-8d0b437a6bb8/removephysicaldisk-fails-with-failover-clustering-and-storage-spaces-in-windows-server-2016?forum=winserverfiles

I used these 4 lines (just replace the 2 parameters that include 'YourXxxXxx'):

$Clustername = "YourClusterName"
Get-CimInstance -Namespace root\mscluster -ComputerName $ClusterName -ClassName MScluster_ClusterService | Invoke-CimMethod -Name EnableHealth
Remove-PhysicalDisk -PhysicalDisks (Get-PhysicalDisk | ? OperationalStatus -eq ‘Lost Communication’) -StoragePoolFriendlyName YourStoragePoolName
Get-CimInstance -Namespace root\mscluster -ComputerName $ClusterName -ClassName MScluster_ClusterService | Invoke-CimMethod -Name DisableHealth