익명 09:41

PowerShell Set-PhysicalDisk when there are identical FriendlyName's

PowerShell Set-PhysicalDisk when there are identical FriendlyName's

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


Top Answer/Comment:

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>}"
상단 광고의 [X] 버튼을 누르면 내용이 보입니다