This post is part of the Automating your Pure Storage Infrastructure series.
    Using PowerCLI to Provision your Pure Storage Infrastructure

Using PowerCLI to Provision your Pure Storage Infrastructure

Share on:

In the continuation of my Automating your Pure Storage Infrastructure blog series, next I will be covering how to use PowerCLI to provision your Pure Storage Infrastructure. This has been one of the most popular ways to automate provisioning, and alot of work has been put into making this an ideal automation solution.

Information on the Pure Storage Powershell Module

There are actually two Pure Storage Powershell Components, the PowershellSDK and the VMware Flasharray Module. Both pages cover how to use and isntall the associated modules.

Installing and Setting up the Powershell Module

Both are available in the Powershell Gallery

  1. Install PureStoragePowerShellSDK using Install-Module -Name PureStoragePowerShellSDK
  2. Install PowerCLI using Install-Module -Name VMware.PowerCLI
  3. Install the Pure Storage FlashArray VMware Module using Install-Module -Name PureStorage.FlashArray.VMware

Using PowerCLI to Provision your Pure Storage Infrastructure

Below is a sample PowerCLI script that will create a volume, two hosts with an ISCSI iqn and then add the hosts and volume to a hostgroup.

 1$vcname = "vc.lab.local"
 2$vcuser = "[email protected]"
 3$vcpass = "VMware1!"
 4$vccluster = "cluster01"
 5$volname = "ds01"
 6$volcapacityTB = "5"
 8$pureendpoint = "flasharray.lab.local"
 9$pureuser = "pureuser"
10$purepass = ConvertTo-SecureString "pureuser" -AsPlainText -Force
11$purecred = New-Object System.Management.Automation.PSCredential -ArgumentList ($pureuser, $purepass)
13#Connect to Flash Array
14$array = New-PfaConnection -endpoint $pureendpoint -credentials $purecred -defaultarray
16#Connect to vCenter Server
17$vc = Connect-VIServer $vcname -User $vcuser -Password $vcpass -WarningAction SilentlyContinue
19#Create Hosts and Hostgroup
20New-PfaHostGroupfromVcCluster -flasharray $array -cluster (Get-Cluster $vccluster -server $vc) -iscsi
22#Configure ESXi Cluster for ISCSI to Flash Array
23Set-ClusterPfaiSCSI -cluster (Get-Cluster $vccluster) -flasharray $array
25#Create Volume, Attach to HostGroup and Provision VMFS Datastore
26New-PfaVmfs -flasharray $array -cluster (Get-Cluster $vccluster -server $vc) -volName $volname -sizeInTB $volcapacityTB
28#Disconnect from vCenter Server
29Disconnect-VIServer -server $vc -Confirm:$false
31#Disconnect Array
32$array = $null

Running your PowerCLI Script

The example above can be found here

To configure your infrastructure run:



When it comes to automating your Pure Storage infrastructure with VMware, I think PowerShell is definitely the way to go. With its tight integration with PowerCLI you can easily manage your Pure Storage and VMware infrastructure in a single script.

Any questions or comments? Leave them below.

comments powered by Disqus

See Also