Highlighted
Contributor
Contributor

cannot set device using esxcli with variable...

Jump to solution

Hi all,

I have the following script which sets the PerenniallyReserved value to TRUE on selected esxi hosts

The storage device id is stored as a variable called $Device and applied as follows:

$PostEsxcli.storage.core.device.setconfig.invoke($false,$Device,$true)

However I receive the following error:

err.jpg

Many thanks

0 Kudos
1 Solution

Accepted Solutions
Highlighted
User Moderator
User Moderator

When you use Get-EsxCli with the V2 switch, the parameters need to be contained in hash table.

See for example Setting RDM on each Host to “PerenniallyReserve... |VMware Communities


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

View solution in original post

0 Kudos
4 Replies
Highlighted
User Moderator
User Moderator

When you use Get-EsxCli with the V2 switch, the parameters need to be contained in hash table.

See for example Setting RDM on each Host to “PerenniallyReserve... |VMware Communities


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

View solution in original post

0 Kudos
Highlighted
Contributor
Contributor

Hi LucD,

Many thanks for your reply and I see now how the three values are applied and what they actually do

Therefore I assume the first value 'sharedclusterwide' will set the RDM to either the individual ESXi host or all ESXi hosts in the cluster based on its value?

Is there any way I can capture this first value per host and keep it current in the set-config per host

or is there a way to simply skip the value completely?

Many thanks for your help!

0 Kudos
Highlighted
User Moderator
User Moderator

The shared-clusterwide parameter is a way to indicate that the specific LUN is shared.

This is for example used by HostProfiles, see Compliance failures with Storage Host Profiles

For the perennially reserved setting, this value has no impact afaik, and you can leave it out (it is marked as optional).

To find all LUNs that are set to SharedClusterwide, you could do

Get-Cluster | Get-VMHost -PipelineVariable esx |

ForEach-Object -Process {

    $esxcli = Get-EsxCli -VMHost $esx -V2

    $esxcli.storage.core.device.list.Invoke() |

    where{$_.IsSharedClusterWide} | Select Device

}


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

0 Kudos
Highlighted
Contributor
Contributor

Thanks LucD,

I now see how the config objects are passed using the array -V2 and have success!

Thank you so much

0 Kudos