VMware Cloud Community
vivekrishna
Enthusiast
Enthusiast
Jump to solution

Esxcli script for powercli

Hi,

I want to run this command on all the hosts in a cluster for enabling the Multipathing for a storage LUN created.

esxcli storage core device set -d <device> -O 256;

esxcli storage nmp device set --device <device> --psp VMW_PSP_RR;

esxcli storage nmp psp roundrobin deviceconfig set --type=iops --iops=1 --device=<device>;

I tried many times using the Powercli, but not able to get a good arguement for the commands, below is the script I have created

$VMhosts = Get-Cluster <ClusterName> | Get-VMHost

foreach($VMhost in $VMhosts){

  $esxcli = get-vmhost $VMhost | Get-EsxCli

  $esxcli.storage.core.device.set($true,$null,<device>,$false,$null,$null,128,$null,$null,$null,$null)

----------------------------------------------------------------

ESXI version 6.0, powercli version 6.5

Thanks,

vivek

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The value is the same as for the regular esxcli command you mentioned.

Yes, you can filter on any property that is returned for a LUN.

All esxcli commands can be done through the Get-EsxCli cmdlet.

See PowerCLI 6.3 R1: Get-ESXCLI Why the V2? for more details.


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

View solution in original post

Reply
0 Kudos
5 Replies
T180985
Expert
Expert
Jump to solution

You dont need to use esxcli, you can change the pathing policy using Set-Scscilun e.g.

Get-Cluster ClusterName | Get-VMHost | Get-ScsiLun -luntype disk | Where {$_.MultipathPolicy -notlike "RoundRobin"} | Set-Scsilun -MultiPathPolicy RoundRobin

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums
Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee
Jump to solution

Moderator: Moved to PowerCLI


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you want to avoid the very slow Get-ScsiLun and Set-ScsiLun cmdlets, you better use the Get-EsxCli cmdlet.

With the introduction of the V2 switch, it also has become a whole lot easier to pass the parameters.

See PowerCLI 6.3 R1: Get-ESXCLI Why the V2? for details on that.

As an example, the following will run the 'esxcli storage core device set' command against each DASD LUN in each ESXi node in a cluster.

You can, of course, adapt the Where-clause to only pick the LUNs you want.

Something like this.

Get-Cluster <ClusterName> | Get-VMHost |

ForEach-Object -Process {

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

  $esxcli.storage.core.device.list.Invoke() | where{$_.DeviceType -eq 'Direct-Access'} |

  ForEach-Object -Process {

    $myArgs = @{

      device = $_.Device

      schednumreqoutstanding = 256

    }

    $esxcli.storage.core.device.set.Invoke($myArgs)

  }

}

You can easily create a skeleton hash table for the Invoke call with the CreateArgs call.

It will show you the type of each parameter and if it is optional or not.


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

Reply
0 Kudos
vivekrishna
Enthusiast
Enthusiast
Jump to solution

Thanks for the sscript, is this value for MaxI/O requests  (NoofoutstandingIOswithcompetingworlds or DEviceMaxQUe Depth) ?

Here I can use my "naa.device" name instead of "Direct access", right ?  $esxcli.storage.core.device.list.Invoke() | where{$_.DeviceType -eq 'Direct-Access'} |

What about these two commands ??

esxcli storage nmp device set --device <device> --psp VMW_PSP_RR;

esxcli storage nmp psp roundrobin deviceconfig set --type=iops --iops=1 --device=<device>;

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The value is the same as for the regular esxcli command you mentioned.

Yes, you can filter on any property that is returned for a LUN.

All esxcli commands can be done through the Get-EsxCli cmdlet.

See PowerCLI 6.3 R1: Get-ESXCLI Why the V2? for more details.


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

Reply
0 Kudos