VMware Cloud Community
Virtualinfra
Commander
Commander
Jump to solution

Set device state to OFF using powercli

#$e = get-esxcli -vmhost esx1

#$lun = get-content lun.txt

Any idea on Equivalent to esxcli storage core device set --state=off -d naa.xx

#$lun | {$e.storage.core.device.set($on, ($_), $off)}

Thanks & Regards Dharshan S VCP 4.0,VTSP 5.0, VCP 5.0
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Assuming that un.txt file contains the device IDs ("naa.xxxxxx"), you can do

$esxcli.storage.core.device.set($_,$null,$false,'on')

where $_ is the device ID, the 2nd parameter is a new name for the device if required (otherwise specify $null).

The 3rd parameter is a Boolean indicating if the device should be non-=persistent or not.

The last parameter defines the state can have 'on' or 'off'.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Assuming that un.txt file contains the device IDs ("naa.xxxxxx"), you can do

$esxcli.storage.core.device.set($_,$null,$false,'on')

where $_ is the device ID, the 2nd parameter is a new name for the device if required (otherwise specify $null).

The 3rd parameter is a Boolean indicating if the device should be non-=persistent or not.

The last parameter defines the state can have 'on' or 'off'.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Virtualinfra
Commander
Commander
Jump to solution

that works perfect.

Thanks & Regards Dharshan S VCP 4.0,VTSP 5.0, VCP 5.0
0 Kudos
Virtualinfra
Commander
Commander
Jump to solution

Is the second parameter $null is Mandatory, instead of $_ what are the option i can use?

Thanks & Regards Dharshan S VCP 4.0,VTSP 5.0, VCP 5.0
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, you have to provide the 2nd parameter, if you don't want to rename the device, give a $null value.

You can list all the available devices, and then get the Device property from that output.

Something like this

$esxcli.storage.core.device.list() | %{
  $esxcli.storage.core.device.set($_.Device,$null,$false,'on')
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos