Skip to main content
Pure Technical Services

How-To: Working with Volumes and the PowerShell SDK v2

Currently viewing public documentation. Please login to access the full scope of documentation.

This article is for the PowerShell SDK version 2. Please refer to this article for working with volumes using the PowerShell SDK version 1.

 

Creating a Single Volume

Creating volumes on the FlashArray is very simple because we remove all of the complexities of needing to define RAID groups or aggregates. All of the below examples of how to work with volumes assumes that an existing connection to the Pure Storage FlashArray has been created using the Connecting to FlashArray topic. 

The PowerShell SDK version 2 does not require a variable for the array once a session is connected, although it can be used as shown in the examples below. A defined variable, such as $FlashArray , would be used to perform tasks against multiple arrays connected in a single PowerShell session.

Let's first create a single volume using the New-Pfa2Volume cmdlet. The only parameters that are required:

  • -Name -- Target volume name.
  • -Provisioned -- Size in bytes of the volume.

Please be aware that the parameters have changed from the SDK version 1 to version 2 for specifying the size of the volumes to be created.

PS > New-Pfa2Volume -Array $FlashArray -Name 'SDKv2-Sample' -Provisioned 10485760
Id                      : cc99ed38-c8a8-4b86-974a-0994aca81831
Name                    : SDKv2-Sample
ConnectionCount         : 0
Created                 : 8/7/2020 6:47:41 PM
Destroyed               : False
HostEncryptionKeyStatus : none
Provisioned             : 10485760
... 

You can use the PowerShell common parameter of -Verbose that shows the exact REST API call in JSON format. This is helpful when wanting to understand what exactly a cmdlet is passing to the REST API.

PS > New-Pfa2Volume -Array $FlashArray -VolumeName 'SDK-Sample' -Provisioned 10485760 -Verbose

 

Creating Multiple Volumes

Creating multiple volumes is just as simple as creating a single volume. To create multiple volumes of the same size, a ForEach loop is used. This example creates 10 volumes that are 10GB each and named incrementally.

PS > ForEach ($i in 1..10) { New-Pfa2Volume -Array $FlashArray -Name "SDKv2-TestSample-$i" -Provisioned 10485760 }

Now that there are ten new volumes created, the next task is to retrieve the volume details for an individual volume using the Get-Pfa2Volume cmdlet.

PS > Get-Pfa2Volume -Array $FlashArray -Name 'SDKv2-TestSample-7'
Id                      : 7f2f8ef2-6853-792b-06db-cac8961752b6
Name                    : SDKv2-TestSample-7
ConnectionCount         : 0
Created                 : 8/7/2020 7:08:17 PM
Destroyed               : False
HostEncryptionKeyStatus : none
Provisioned             : 10485760
...

To retrieve all volumes on the FlashArray, use the same Get-PfaVolume cmdlet. There are several hundred volumes on the FlashArray being used to write these samples so a Where-Object clause is used to only retrieve the SDKv2-TestSample volumes. When retrieving multiple items, it is suggested to use the Format options with Windows PowerShell to make the results easily readable. 

PS > Get-Pfa2Volume -Array $FlashArray | Where-Object { $_.name -like 'SDKv2-TestSample*' } | Format-Table -AutoSize

Id                                   Name                ConnectionCount Created             Destroyed HostEncryptionKeyStatus Provisioned Qos
--                                   ----                --------------- -------             --------- ----------------------- ----------- ---
6ccfc3a8-9378-18d7-9c41-c9ccb9d2dd07 SDKv2-TestSample-1                0 8/7/2020 7:08:15 PM     False none                       10485760 class Qos {…
27cf40a1-f110-8324-e223-02cb38729108 SDKv2-TestSample-2                0 8/7/2020 7:08:15 PM     False none                       10485760 class Qos {…
46beda12-7ff0-0f14-c235-495623569cc4 SDKv2-TestSample-3                0 8/7/2020 7:08:15 PM     False none                       10485760 class Qos {…
c69fca32-a581-ead1-e59c-03f33274e4bb SDKv2-TestSample-4                0 8/7/2020 7:08:16 PM     False none                       10485760 class Qos {…
23097fd8-0186-2145-0e6d-15bcc3097648 SDKv2-TestSample-5                0 8/7/2020 7:08:16 PM     False none                       10485760 class Qos {…
c4645c08-1c91-642a-d9c1-25bc223fa55f SDKv2-TestSample-6                0 8/7/2020 7:08:16 PM     False none                       10485760 class Qos {…
7f2f8ef2-6853-792b-06db-cac8961752b6 SDKv2-TestSample-7                0 8/7/2020 7:08:17 PM     False none                       10485760 class Qos {…
6d989deb-b4cf-0582-4f8b-d7765dd65c6f SDKv2-TestSample-8                0 8/7/2020 7:08:17 PM     False none                       10485760 class Qos {…
...

Renaming a Volume

Renaming a volume can be accomplished using the Update-Pfa2Volume cmdlet and can come in handy after creating a single or multiple volumes without the need to destroy the volume and create with the new name. In the below example, the SDKv2-TestSample-5 volume is renamed to SDKv2-Rename-5. We use the Get-PfaVolume cmdlet again to show all of the volumes like 'SDKv2-*'.

PS > Update-Pfa2Volume -Array $FlashArray -VolumeName 'SDKv2-Rename-5' -Name 'SDKv2-TestSample-5'

PS > Get-Pfa2Volume -Array $FlashArray | Where-Object { $_.name -like 'SDKv2-*' } | Format-Table -AutoSize
Id                                   Name                ConnectionCount Created             Destroyed HostEncryptionKeyStatus Provisioned Qos
--                                   ----                --------------- -------             --------- ----------------------- ----------- ---
2245a634-7bd9-55c8-d22a-0e4e17bbe9f7 SDKv2-sample-3                    0 8/7/2020 3:07:24 PM     False none                     2147483648 class Qos {…
d73e3c73-c0d4-6982-c377-d70f0e813b63 SDKv2-sample-2                    1 8/7/2020 3:07:24 PM     False none                     2147483648 class Qos {…
d59bbc70-ca3a-4c61-7c6e-b5ac0ba54ea4 SDKv2-sample-1                    0 8/7/2020 3:07:24 PM     False none                     2147483648 class Qos {…
65693c17-0877-8024-81cf-bc45f252dd43 SDKv2-Sample                      0 8/7/2020 6:56:11 PM     False none                       10485760 class Qos {…
6ccfc3a8-9378-18d7-9c41-c9ccb9d2dd07 SDKv2-TestSample-1                0 8/7/2020 7:08:15 PM     False none                       10485760 class Qos {…
27cf40a1-f110-8324-e223-02cb38729108 SDKv2-TestSample-2                0 8/7/2020 7:08:15 PM     False none                       10485760 class Qos {…
46beda12-7ff0-0f14-c235-495623569cc4 SDKv2-TestSample-3                0 8/7/2020 7:08:15 PM     False none                       10485760 class Qos {…
c69fca32-a581-ead1-e59c-03f33274e4bb SDKv2-TestSample-4                0 8/7/2020 7:08:16 PM     False none                       10485760 class Qos {…
23097fd8-0186-2145-0e6d-15bcc3097648 SDKv2-Rename-5                    0 8/7/2020 7:08:16 PM     False none                       10485760 class Qos {…
c4645c08-1c91-642a-d9c1-25bc223fa55f SDKv2-TestSample-6                0 8/7/2020 7:08:16 PM     False none                       10485760 class Qos {…

Volume Snapshots

For information on working with snapshots with the SDK v2, please see this article.

Volume Space and Metrics

There are PowerShell cmdlets that provide space and metric information that can be useful in reporting scenarios.

Use the following command to get all the available cmdlets that have performance in their names:

PS >Get-Command -Module PureStoragePowerShellSDK2 *Performance*

When using the space metric cmdlets, the system space will not have a value as that is only reported at the FlashArray level. To get that information, use the Get-Pfa2ArrayPerformance.

As an example, we want to see a Volume performance metric rundown for all volumes on an array during a time period of 24 hours (-starttime and -endtime), with the number of milliseconds between the historical data set at 8 hours (-resolution). The command would look similar to this:

 Get-Pfa2ArrayPerformance -endtime '2020-08-07T01:00:00Z' -starttime '2020-08-06T01:00:00Z' -resolution 28800000

The output from that command can be very long and it contains many fields. To export it to a CSV file for easier viewing and manipulation, use this command:

Get-Pfa2ArrayPerformance -endtime '2020-08-07T01:00:00Z' -starttime '2020-08-06T01:00:00Z' -resolution 28800000 | Export-Csv -Path ‘C:\temp\test.csv'

The same parameters could be used for the Get-Pfa2ArraySpace cmdlet, as shown below:

Get-Pfa2ArraySpace -Array $FlashArray -endtime '2020-08-07T01:00:00Z' -starttime '2020-08-06T01:00:00Z' -resolution 28800000

This is a listing of performance and space metrics cmdlets that are available in the SDK. Please refer to the Release Notes of any future versions for any updated or added cmdlets.

Array
  • Get-Pfa2ArrayPerformance
  • Get-Pfa2ArraySpace
Host
  • Get-Pfa2HostPerformance
  • Get-Pfa2HostPerformanceByArray
  • Get-Pfa2HostGroupPerformance
  • Get-Pfa2HostGroupPerformanceByArray
Pods
  • Get-Pfa2PodSpace
  • Get-Pfa2PodPerformance
  • Get-Pfa2PodPerformanceByArray
  • Get-Pfa2PodPerformanceReplication
  • Get-Pfa2PodPerformanceReplicationByArray
  • Get-Pfa2PodReplicaLinkLag
  • Get-Pfa2PodReplicaLinkPerformanceReplication
Protection Groups
  • Get-Pfa2ProtectionGroupSpace
  • Get-Pfa2ProtectionGroupPerformanceReplication
  • Get-Pfa2ProtectionGroupPerformanceReplicationByArray
Volumes
  • Get-Pfa2VolumeGroupPerformance
  • Get-Pfa2VolumeGroupSpace
  • Get-Pfa2VolumePerformance
  • Get-Pfa2VolumePerformanceByArray