PowerCLI Script to Create VMware Clusters on the FlashArray

The first step prior to provisioning storage on the FlashArray is to actually create the host records on the array itself. These records, in their most basic form, are just names of hosts with associated WWNs or IQNs. Pretty simple process in general, but as these VMware clusters get larger and larger (vSphere 6.0 now allows 64 hosts per cluster) scripting this configuration becomes a bit more appealing. Granted, this is a one-off operation, but still saves you from a tedious task. So I wrote one. This script also integrates setting the best practices on the ESXi hosts in the cluster and in the case of iSCSI adds the FlashArray iSCSI ports as a target on the host software iSCSI adapters.


This is the first script I have the used the Pure Storage PowerShell toolkit (yes, I know, shame on me!). Previously, I have been using PowerShell to just make direct REST calls with Invoke-RestMethod. Works fine, but requires a solid knowledge of what calls to make and how to make them. Not ideal. The toolkit makes it a bajillion times easier.

Download it here, install it, and add Import-Module PureStoragePowerShell to your scripts and thank me later. Or you can thank me now. That works too.

The script, as mentioned above, does a few different things. It takes in a VMware cluster and creates a host group on the FlashArray using the cluster name. It also takes each ESXi host name and creates a host record on the FlashArray and adds them all to the host group. The WWNs or IQNs are grabbed from the hosts and added respectively on the array. The FlashArray host and host group naming is a bit stricter than the ESXi and VMware cluster rules so some changes have to be made in certain situations–the script takes care of this by altering the name slightly when adding it to the FlashArray.



The script also configures the Pure Storage best practices by creating a SATP rule so that all FlashArray devices will be set to Round Robin with an IO Operations Limit of 1. The XCOPY setting, MaxHWTransferSize is also set to 16 MB.

In the case of iSCSI the FlashArray targets in the software iSCSI initiator are also set to have DelayedAck disabled and an increased LoginTimeout of 30 seconds. This is set on the dynamic target that is added so that all of the static targets automatically inherit these settings.



Note that this script only works with Fibre Channel or Software iSCSI adapters (which have to be created prior to the script).

You can find the script here:


Leave a Reply

Your email address will not be published.