#$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)}
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
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
that works perfect.
Is the second parameter $null is Mandatory, instead of $_ what are the option i can use?
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