Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • Thanks, but I found out that the serial number of a HDD isn't necessarily unique and that, even though collisions are probably rare, there is a better way to find the correct disk number.
    – willy
    Commented Jan 9, 2013 at 23:48
  • Assuming $diid is a string which holds the device instance ID of the HDD, $disks = gwmi win32_diskdrive | ? pnpdeviceid -eq $diid $c = @($disks).count if ($c -eq 1) { $diskid = $disks.index $dpscript = @" sel disk $diskid offline disk exit "@ $dpscript | diskpart } else { write-host "ERROR" }
    – willy
    Commented Jan 9, 2013 at 23:59