Powershell/Powercli to build Nimble Storage LUNs and build Datastores in VMware

I recently added Nimble storage to my cloud environment. At first this was just for my management cluster. With the latest storage expansion this system will be moving to my production cloud environment. With this change upcoming I decided it was time to figure out how to automate the datastore build process. I will have several to build soon. After some research i found that Nimble does have a powershell module. It's name is HPENimblePowershellToolkit. it can be found in the powershell gallery.


To install, be sure to open powershell as an administrator and run Install-Module HPENimblePowershellToolkit and follow the prompts to install.

Lets walk through the script;

First as usual we have to connect to the Nimble. Be sure to add your Management IP or FQDN in the ""

Once connected we will need the policy ID from the Nimble VMware ESX 5 performance profile. For this script I will only be provisioning VMware LUNs. The pre-defined policys can be found by using the Get-NSPerformancePolicy command. Next we will need the ID for all the Initiator groups. I have each of my host setup as an initiator group. This info can be found by using the Get-NSInitiatorGroup. Once I have this data I created variables with it.

Next the script will ask a couple questions for a few more variables. Then the new volume will be created.

To get the volume seen by the host we need the Volume ID. When getting this info with powershell there are extra characters with the output. I had to use the replace command to get rid of these characters. Once that is complete we can assign the volume to the initiator groups.

Now to connect to vCenter and rescan the HBA's to see the new storage. Then find the free LUN. I did some research on this part and found a function that was written. The Function can be found here; http://vcloud-lab.com/entries/powercli/find-free-or-unassigned-storage-lun-disks-on-vmware-esxi-server

Once we have the data on the new nimble storage we can create a new datastore. Then one final refresh to get all the host in the cluster to see it.

There you have it. A new volume has been built and presented to VMware. Then a new datastore is ready to go.

the full script can be downloaded from my github here;


Thanks for reading.