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 more information on working with snapshots with the SDK v2, please see this article.

Creating snapshots for volumes is done using the New-Pfa2VolumeSnapshot cmdlet.

PS >New-Pfa2VolumeSnapshots -Array $FlashArray -SourceNames 'SDKv2-sample-1','SDKv2-sample-2' -Suffix 'EXAMPLE'

To create a new volume from a snapshot, we must first create a Reference Object for the snapshot. The first output from Get-Pfa2VolumeSnapshot is trimmed to only show the necessary objects.

PS >Get-Pfa2VolumeSnapshot -Name 'SDKv2-sample-1.EXAMPLE'
    Id            : 47f25a22-fda3-f163-c695-94a6c984b0af
    Name          : SDKv2-sample-1.EXAMPLE
    ...
PS >$src = New-Pfa2ReferenceObject -Id 47f25a22-fda3-f163-c695-94a6c984b0af -Name SDKv2-sample-1.EXAMPLE

Now, we will create a new volume from the snapshot using New-Pfa2Volume.

PS >New-Pfa2Volume -Name SDKv2-volumecopy -Source $src

Manage FlashArray Volume(s) from Windows Server Host

Rescan/update the Windows Server host SERVER01 to see the new volumes

PS C:\> Update-HostStorageCache

View the currently connected volumes to the Windows Server host

PS C:\> Get-Disk

Number Friendly Name         Serial Number                    HealthStatus         OperationalStatus      Total Size Partition Style
------ -------------         -------------                    ------------         -----------------      ---------- ----------
1      PURE FlashArray       45084F3508BF461400011ACB         Healthy              Online                       1 TB RAW
2      PURE FlashArray       45084F3508BF461400011ACC         Healthy              Online                       1 TB RAW
0      PURE FlashArray       73E940225A2A52BB0003AE86         Healthy              Online                     150 GB MBR

If the SAN Policy of the Windows Server host is kept at the default of OfflineShared when the volumes are connected to the host they will not come online automatically. Performing a Get-Disk will indicate that they have an OperationalStatus of Offline.

PS C:\> Get-Disk

Number Friendly Name     Serial Number                    HealthStatus         OperationalStatus      Total Size Partition Style     
------ -------------     -------------                    ------------         -----------------      ---------- ----------
1      PURE FlashArray   45084F3508BF461400011ACB         Healthy              Offline                      1 TB GPT       
2      PURE FlashArray   45084F3508BF461400011ACC         Healthy              Offline                      1 TB GPT       
0      PURE FlashArray   73E940225A2A52BB0003AE86         Healthy              Online                     150 GB MBR 

PS C:\> Get-Disk | Where-Object { $_.OperationalStatus -eq 'Offline' } | Set-Disk -IsOffline $False
PS C:\> Get-Disk

Number Friendly Name     Serial Number                    HealthStatus         OperationalStatus      Total Size Partition Style     
------ -------------     -------------                    ------------         -----------------      ---------- ----------
1      PURE FlashArray   45084F3508BF461400011ACB         Healthy              Online                       1 TB GPT       
2      PURE FlashArray   45084F3508BF461400011ACC         Healthy              Online                       1 TB GPT       
0      PURE FlashArray   73E940225A2A52BB0003AE86         Healthy              Online                     150 GB MBR   

Initialize the new volumes

Set the -Number parameter from the output of Get-Disk. The Partition Style has been updated from RAW to GPT.

PS C:\> Initialize-Disk -Number 1 -PartitionStyle GPT
PS C:\> Initialize-Disk -Number 2 -PartitionStyle GPT
PS C:\> Get-Disk

Number Friendly Name       Serial Number                    HealthStatus         OperationalStatus      Total Size Partition Style
------ -------------       -------------                    ------------         -----------------      ---------- ----------
1      PURE FlashArray     45084F3508BF461400011ACB         Healthy              Online                       1 TB GPT
2      PURE FlashArray     45084F3508BF461400011ACC         Healthy              Online                       1 TB GPT
0      PURE FlashArray     73E940225A2A52BB0003AE86         Healthy              Online                     150 GB MBR

Create a new partition

PS C:\> New-Partition -DiskNumber 1 -UseMaximumSize -AssignDriveLetter

   DiskPath: \\?\mpio#disk&ven_pure&prod_flasharray&rev_8888#1&7f6ac24&0&3632344139333730343530383446333530384246343631343030303131414342#{53f
56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                                    Size Type
---------------  ----------- ------                                                    ---- ----
2                D           135266304                                           1023.87 GB Basic

PS C:\> New-Partition -DiskNumber 2 -UseMaximumSize -AssignDriveLetter

   DiskPath: \\?\mpio#disk&ven_pure&prod_flasharray&rev_8888#1&7f6ac24&0&3632344139333730343530383446333530384246343631343030303131414343#{53f
56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                                    Size Type
---------------  ----------- ------                                                    ---- ----
2                E           135266304                                           1023.87 GB Basic

PS C:\> Get-Volume

DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining      Size
----------- --------------- ---------- --------- ------------ ----------------- -------------      ----
D                                      Fixed     Healthy      Unknown                     0 B       0 B
            System Reserved NTFS       Fixed     Healthy      OK                       169 MB    500 MB
C                           NTFS       Fixed     Healthy      OK                    117.59 GB 149.51 GB
E                                      Fixed     Healthy      Unknown                     0 B       0 B

Format volumes as NTFS and ReFS

The below examples set the AllocationUnitSize (cluster size) to 64KB.

PS C:\> Format-Volume -DriveLetter D -FileSystem NTFS -NewFileSystemLabel 'NTFS' -AllocationUnitSize 64KB

DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining       Size
----------- --------------- ---------- --------- ------------ ----------------- -------------       ----
D           NTFS            NTFS       Fixed     Healthy      OK                    1023.7 GB 1023.87 GB

PS C:\> Format-Volume -DriveLetter E -FileSystem ReFS -NewFileSystemLabel 'ReFS' -AllocationUnitSize 64KB

DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining       Size
----------- --------------- ---------- --------- ------------ ----------------- -------------       ----
E           ReFS            ReFS       Fixed     Healthy      OK                   1018.03 GB 1023.81 GB

PS C:\> Get-Volume

DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining       Size
----------- --------------- ---------- --------- ------------ ----------------- -------------       ----
D           NTFS            NTFS       Fixed     Healthy      OK                    1023.7 GB 1023.87 GB
            System Reserved NTFS       Fixed     Healthy      OK                       169 MB     500 MB
C                           NTFS       Fixed     Healthy      OK                    117.59 GB  149.51 GB
E           ReFS            ReFS       Fixed     Healthy      OK                   1018.03 GB 1023.81 GB

Create Mounts Point(s) (Optional)

This is an optional step and shows how to create Partition Access Paths (mount points) for volumes. 

Retrieve the partition details in order to see the PartitionNumber which is required for creating a PartitionAccessPath.

PS C:\> Get-Partition

   DiskPath: \\?\mpio#disk&ven_pure&prod_flasharray&rev_8888#1&7f6ac24&0&3632344139333730343530383446333530384246343631343030303131414342#{53f
56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                                    Size Type
---------------  ----------- ------                                                    ---- ----
1                            17408                                                   128 MB Reserved
2                D           135266304                                           1023.87 GB Basic

   DiskPath: \\?\mpio#disk&ven_pure&prod_flasharray&rev_8888#1&7f6ac24&0&3632344139333730343530383446333530384246343631343030303131414343#{53f
56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                                    Size Type
---------------  ----------- ------                                                    ---- ----
1                            17408                                                   128 MB Reserved
2                E           135266304                                           1023.87 GB Basic

   DiskPath: \\?\mpio#disk&ven_pure&prod_flasharray&rev_8888#1&7f6ac24&0&3632344139333730373345393430323235413241353242423030303341453836#{53f
56307-b6bf-11d0-94f2-00a0c91efb8b}

PartitionNumber  DriveLetter Offset                                                    Size Type
---------------  ----------- ------                                                    ---- ----
1                            1048576                                                 500 MB IFS
2                C           525336576                                            149.51 GB IFS

Create a directory that will be assigned to the new volume

PS C:\> New-Item -Path 'C:\FlashArrayMounts\NTFS' -ItemType Directory

    Directory: C:\FlashArrayMounts
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        5/23/2017   3:50 PM                NTFS

PS C:\> New-Item -Path 'C:\FlashArrayMounts\ReFS' -ItemType Directory

    Directory: C:\FlashArrayMounts
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        5/23/2017   3:50 PM                ReFS

 Add the mount points for the individual volumes. Use the PartitionNumber retrieved from Step 1 for the new drives (D and E) 

PS C:\> Add-PartitionAccessPath -DiskNumber 1 -AccessPath 'C:\FlashArrayMounts\NTFS' -PartitionNumber 2
PS C:\> Add-PartitionAccessPath -DiskNumber 2 -AccessPath 'C:\FlashArrayMounts\ReFS' -PartitionNumber 2

View the new mount points 

PS C:\> cd C:\FlashArrayMounts\
PS C:\FlashArrayMounts> ls
    Directory: C:\FlashArrayMounts
    
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d----l        5/23/2017   3:50 PM                NTFS
d----l        5/23/2017   3:50 PM                ReFS

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