I ran Get-PhysicalDisk inside a virtual machine which has 4 hard disks. The result was:

FriendlyName SerialNumber CanPool OperationalStatus HealthStatus Usage Size ------------ ------------ ------- ----------------- ------------ ----- ---- VMware, VMware Virtual S False OK Healthy Auto-Select 60 GB VMware, VMware Virtual S False OK Healthy Auto-Select 100 GB VMware, VMware Virtual S False OK Healthy Auto-Select 200 GB VMware, VMware Virtual S False OK Healthy Auto-Select 400 GB 

There were no SerialNumber's or any other unique ID that I could see in the result above.

Now, I need to run Set-PhysicalDisk. All examples on the web use the unique FriendlyName or something like PhysicalDisk1. First, there are 4 disks with the same FriendlyName's, so I think I cannot use it. Secondly, I thought PhysicalDisk{number} was a special name to point a disk by the index, but it did not seem to work.

What should I pass to Set-PhysicalDisk, if I want to designate, say, the second disk above (size = 100GB)?

PS C:\Users\Administrator> Set-PhysicalDisk -FriendlyName "VMware, VMware Virtual S" -Usage Retired Set-PhysicalDisk : Not Supported At line:1 char:1 + Set-PhysicalDisk -FriendlyName "VMware, VMware Virtual S" -Usage Reti ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (StorageWMI:ROOT/Microsoft/..._StorageCmdlets) [Set-PhysicalDisk], CimException + FullyQualifiedErrorId : StorageWMI 1,Set-PhysicalDisk PS C:\Users\Administrator> Set-PhysicalDisk PhysicalDisk1 -Usage Retired Set-PhysicalDisk : The requested object could not be found. At line:1 char:1 + Set-PhysicalDisk PhysicalDisk1 -Usage Retired + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (PS_StorageCmdlets:ROOT/Microsoft/..._StorageCmdlets) [Set-PhysicalDisk], CimException 
3

3 Answers

You can Set-PhysicalDisk by using the UniqueID.

To retrieve the UniqueID,

Get-PhysicalDisk | Select-Object SerialNumber,UniqueID 

To make updates based on the UniqueID,

Set-PhysicalDisk -UniqueId "{<insert_UniqueID>}" 
1

You can assign that disk "object" to a variable. With that variable you can perform the operations on the variable itself - all without even needing a FriendlyName or SerialNumber

Details

In my case i had no FriendlyName, nor any SerialNumber:

FriendlyName CanPool OperationalStatus HealthStatus Usage Size ------------ ------- ----------------- ------------ ----- ---- PhysicalDisk1 False OK Healthy Auto-Select 1.82 TB PhysicalDisk3 False OK Healthy Auto-Select 1.82 TB PhysicalDisk4 False OK Healthy Auto-Select 1.82 TB PhysicalDisk0 False OK Healthy Auto-Select 111.79 GB PhysicalDisk8 False OK Healthy Auto-Select 1.82 TB PhysicalDisk2 False OK Healthy Auto-Select 465.76 GB False Lost Communication Warning Retired 930.75 GB PhysicalDisk6 False OK Healthy Auto-Select 930.75 GB PhysicalDisk9 False OK Healthy Auto-Select 930.75 GB PhysicalDisk7 False OK Healthy Auto-Select 1.82 TB PhysicalDisk5 False OK Healthy Auto-Select 1.82 TB 

The easiest thing i could key on was that the OperationalStatus said Lost Communication:

#Single out the disk that has lost communication Get-PhysicalDisk | Where-Object { $_.OperationalStatus -eq 'Lost Communication' } 

From there i can assign that disk to a variable:

#Assign the missing disk to a variable $missingDisk = Get-PhysicalDisk | Where-Object { $_.OperationalStatus -eq 'Lost Communication' } 

Now that i have a variable object, i can mark that disk as retired:

#tell the storage pool that the disk has been retired: $missingDisk | Set-PhysicalDisk -Usage Retired 

And then to top it off, repair all volumes on the storage space that were affected:

# To Repair all Warning Volumes Get-VirtualDisk | Where-Object –FilterScript {$_.HealthStatus –Eq 'Warning'} | Repair-VirtualDisk 

You can confirm that a virtual disk is being repaired by seeing that its OperationStatus is InService:

#Disks will show as `InService` to let us know that they're currently being repaired Get-VirtualDisks FriendlyName ResiliencySettingName OperationalStatus HealthStatus IsManualAttach Size ------------ --------------------- ----------------- ------------ -------------- ---- Three-way mirror Mirror InService Warning False 10 TB PooledParityDisk Parity InService Warning False 15 TB 

And finally you can monitor the progress of the repair:

#Monitor the percentage of the repair Get-StorageJob Name ElapsedTime JobState PercentComplete IsBackgroundTask ---- ----------- -------- --------------- ---------------- Regeneration 00:00:00 Running 40 True Regeneration 00:00:00 New 0 True 

Thanks to Matthew Hodgkins. (archive)

p.s. the person thinking PowerShell is a good idea should be shot

When I run into this issue, I turn to Select-Object ()

This isn't terribly elegant, but if you can list your objects and know you want only specific ones, you can array index them with Select-Object.

i.e. if you want to operate on the third hard drive:

Get-PhysicalDisk | Select-Object -Index 2 | Set-PhysicalDisk...

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy