Default FlashArray Connection With PowerShell

In the VMware Pure PowerShell module (PureStorage.FlashArray.VMware) there is a default array connection stored in a global variable called $Global:DefaultFlashArray and all connected FlashArrays in $Global:AllFlashArrays. The VMware/Pure PowerShell module automatically uses what is in the “default” variable.

The underlying “core” Pure Storage PowerShell module (PureStoragePowerShellSDK) does not yet take advantage of global connections. So for each cmdlet you run, you must pass in the “array” parameter. For example to get all of the volumes from an array:

Kind of annoying if you are interactively running commands and only have one array connection you care about (or one that you primarily care about).

But there is a nice option in PowerShell to help you with this! Default parameter values. In every cmdlet the input for the array connection is -array.

So let’s say I use new-pfaarray to create a new FlashArray connection and store the connection in the variable $flasharray.

$flasharray = new-pfaarray -endpoint -credentials (get-credential) -ignoreCertificateError 

I can then run this:

$PSDefaultParameterValues = @{


This will then default any parameter named “array” to the value in $flasharray of the parameter was not specifically entered. Furthermore, it will be only for cmdlets with -pfa in their name, which generally should therefore only be for cmdlets in the PureStoragePowerShellSDK. I looked at ways of including the fully-qualified module name in the default parameter rule (only default the “-array” parameter if the cmdlet is in this module) and there doesn’t seem to be a clean way to do that other than explicitly grabbing each cmdlet and making a rule for it.

This is also fairly straight-forward. Once again, connect to a FlashArray:

flasharray = new-pfaarray -endpoint -credentials (get-credential) -ignoreCertificateError 

Then run:

$psCMDs = (get-command -Module PureStoragePowerShellSDK).Name
$defaultParamHash = @{}
foreach ($psCMD in $psCMDs)
$PSDefaultParameterValues = $defaultParamHash

The above pulls all of the cmdlets from the PureStoragePowerShellSDK module and make a specific rule for each (if “array” is not specified, default to this value (specified array connection).

Either of the above options will result in you no longer having to explicitly pass in a FlashArray connection each time you run a base PureStoragePowerShellSDK command:

3 Replies to “Default FlashArray Connection With PowerShell”

  1. Hi Cody,
    I wanted to get a list of all the flash arrays that are connected to my vcenter. Is there a way to do it from PowerCLI ?

    According to my use case, I need to know the IP of a flash array connected to a particular DataStore.

    1. If you use the module here:

      This is possible with the cmdlet get-pfaconnectionofdatastore. Just connect to your FlashArrays and then pass in a datastore to the cmdlet and it will tell you which FA hosts it. The FA object which is returned has a property called .endpoint which will be the FQDN or IP of the FlashArray.


      PS C:\Users\cody> get-help Get-PfaConnectionOfDatastore -Detailed


      Takes in a vVol or VMFS datastore, one or more FlashArray connections and returns the correct connection.

      Get-PfaConnectionOfDatastore [[-flasharrays] ] [-datastore] []

      Will iterate through any connections stored in $Global:AllFlashArrays or whatever is passed in directly.



      This cmdlet supports the common parameters: Verbose, Debug,
      ErrorAction, ErrorVariable, WarningAction, WarningVariable,
      OutBuffer, PipelineVariable, and OutVariable. For more information, see
      about_CommonParameters (https:/

      ————————– EXAMPLE 1 ————————–

      PS C:\>PS C:\ $faCreds = get-credential

      PS C:\ New-PfaConnection -endpoint flasharray-m20-2 -credentials $faCreds -defaultArray
      PS C:\ New-PfaConnection -endpoint flasharray-x70-1 -credentials $faCreds -nondefaultArray
      PS C:\ New-PfaConnection -endpoint flasharray-x70-2 -credentials $faCreds -nondefaultArray
      PS C:\ $ds = get-datastore MyDatastore
      PS C:\ Get-PfaConnectionOfDatastore -datastore $ds

      1. For making connections to the flash arrays, I should know the endpoints of them. Let’s assume that I am unaware of the flash arrays that are connected but I want to establish a connection to all of them. Is there a way to find out all the flash arrays in my vCenter ?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.