'Take a disk offline from powershell

normally to take a disk offline I use the windows disk partition manager. now i would need to do it with a power shell using the drive letter. I tried with the command:

Set-Partition -DriveLetter E -IsOffline $True

i get this error from powershell:

Set-Partition : The volume still has access path to it.

you have suggestions



Solution 1:[1]

I solved it like this:

set-disk (get-partition -DriveLetter E | get-disk | select number -ExpandProperty number) -isOffline $true

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mnhmilu