PowerShell script to offline and online a disk

PowerShell script to offline and online a disk

First, we need to find out the disk number ,for that run the following command

get-disk

It will list all available disk and note the "number"

enter image description here

Set-Disk syntax follows,

Set-Disk
   [-Number] <UInt32>
   [-IsReadOnly <Boolean>]
   [-Signature <UInt32>]
   [-Guid <String>]
   [-CimSession <CimSession[]>]
   [-ThrottleLimit <Int32>]
   [-AsJob]
   [<CommonParameters>]

To offline a disk execute the following command.From the below command change the disk number,

set-disk 6 -ErrorAction Stop -IsOffline $true 

To Online a disk execute

set-disk 6 -ErrorAction Stop -IsOffline $false

Comments