Skip to main content
Pure Technical Services

How-To: Working with Volumes with the PowerShell SDK v1

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

KP_Ext_Announcement.png

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

In this section we will cover:

Volume Snapshots

Please refer to this article for working with snapshots and the PowerShell SDK v1.

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. 

Remember from the Connecting to FlashArray topic that the $FlashArray variable will be used to perform tasks against the authenticated FlashArray.

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

  • -VolumeName -- Target volume name.
  • -Unit -- Valid unit symbols are K, M, G, T, P, representing KiB, MiB, GiB, TiB, and PiB, respectively, where "Ki" denotes 2^10, "Mi" denotes 2^20, and so on.
  • -Size -- Size in bytes of the volume.
PS C:\> New-PfaVolume -Array $FlashArray -VolumeName 'SDK-Sample' -Unit G -Size 500

source  :
serial  : 95DAA3D006E43D8F0004B467
created : 2016-11-01T21:30:47Z
name    : SDK-Sample
size    : 536870912000

The New-PfaVolume cmdlet has a -WhatIf parameter 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 C:\> New-PfaVolume -Array $FlashArray -VolumeName 'SDK-Sample' -Unit G -Size 500 -WhatIf
What if: Performing the operation "New-PfaVolume" on target "
POST https://10.0.0.1/api/1.7/volume/SDK-Sample
{
  "size": "500G"
}".

 

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.

PS C:\> ForEach ($i in 1..10) { New-PfaVolume -Array $FlashArray -VolumeName "SDK-Sample-$i" -Unit M -Size 250 }
source  :
serial  : 95DAA3D006E43D8F0004B468
created : 2016-11-01T21:41:16Z
name    : SDK-Sample-1
size    : 262144000

source  :
serial  : 95DAA3D006E43D8F0004B469
created : 2016-11-01T21:41:17Z
name    : SDK-Sample-2
size    : 262144000

source  :
serial  : 95DAA3D006E43D8F0004B46A
created : 2016-11-01T21:41:17Z
name    : SDK-Sample-3
size    : 262144000

source  :
serial  : 95DAA3D006E43D8F0004B46B
created : 2016-11-01T21:41:17Z
name    : SDK-Sample-4
size    : 262144000

source  :
serial  : 95DAA3D006E43D8F0004B46C
created : 2016-11-01T21:41:17Z
name    : SDK-Sample-5
size    : 262144000

source  :
serial  : 95DAA3D006E43D8F0004B46D
created : 2016-11-01T21:41:17Z
name    : SDK-Sample-6
size    : 262144000

source  :
serial  : 95DAA3D006E43D8F0004B46E
created : 2016-11-01T21:41:17Z
name    : SDK-Sample-7
size    : 262144000

source  :
serial  : 95DAA3D006E43D8F0004B46F
created : 2016-11-01T21:41:17Z
name    : SDK-Sample-8
size    : 262144000

source  :
serial  : 95DAA3D006E43D8F0004B470
created : 2016-11-01T21:41:17Z
name    : SDK-Sample-9
size    : 262144000

source  :
serial  : 95DAA3D006E43D8F0004B471
created : 2016-11-01T21:41:18Z
name    : SDK-Sample-10
size    : 262144000

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

PS C:\> Get-PfaVolume -Array $FlashArray -Name 'SDK-Sample-7'

name           : SDK-Sample-7
created        : 2016-11-01T21:41:17Z
source         :
time_remaining :
serial         : 95DAA3D006E43D8F0004B46E
size           : 262144000

Next is to retrieve all volumes on the FlashArray using the Get-PfaVolumes 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 SDK-Sample volumes. When retrieving multiple items, it is suggested to use the Format options with Windows PowerShell to make the results easily readable. 

PS C:\> Get-PfaVolumes -Array $FlashArray | Where-Object { $_.name -like 'SDK-Sample*' } | Format-Table -AutoSize

source serial                   created              name                  size
------ ------                   -------              ----                  ----
       95DAA3D006E43D8F0004B467 2016-11-01T21:30:47Z SDK-Sample    536870912000
       95DAA3D006E43D8F0004B468 2016-11-01T21:41:16Z SDK-Sample-1     262144000
       95DAA3D006E43D8F0004B469 2016-11-01T21:41:17Z SDK-Sample-2     262144000
       95DAA3D006E43D8F0004B46A 2016-11-01T21:41:17Z SDK-Sample-3     262144000
       95DAA3D006E43D8F0004B46B 2016-11-01T21:41:17Z SDK-Sample-4     262144000
       95DAA3D006E43D8F0004B46C 2016-11-01T21:41:17Z SDK-Sample-5     262144000
       95DAA3D006E43D8F0004B46D 2016-11-01T21:41:17Z SDK-Sample-6     262144000
       95DAA3D006E43D8F0004B46E 2016-11-01T21:41:17Z SDK-Sample-7     262144000
       95DAA3D006E43D8F0004B46F 2016-11-01T21:41:17Z SDK-Sample-8     262144000
       95DAA3D006E43D8F0004B470 2016-11-01T21:41:17Z SDK-Sample-9     262144000
       95DAA3D006E43D8F0004B471 2016-11-01T21:41:18Z SDK-Sample-10    262144000

Connecting Volumes to Windows Hosts

New-PfaHostVolumeConnection -Array $FlashArray -VolumeName 'SDK-Sample' -HostName 'SERVER01'

Connecting Volumes to Host Groups

If the volumes need to be visible to a cluster of Windows Server hosts then they need to be connected to a Host Group. The following steps show how to create a Host Group, add a Host and then connect the volume to the Host Group.

PS C:\> New-PfaHostGroup -Array $f -Hosts 'SERVER01' -Name 'HOSTGROUP1'
PS C:\> New-PfaHostGroupVolumeConnection -Array $FlashArray -VolumeName 'SDK-Sample' -HostGroupName 'HOSTGROUP1'

Creating a Volume from a Protection Group Snapshot

When creating new volumes (Copy Volume) from a Protection Group snapshot, the naming convention is the devil in the details. By not using the correct name of the Protection Group snapshot source, The creation of the volume will fail. Below is an example using the Pure Storage PowerShell SDK.

# Connect to FlashArray.
$f = New-PfaArray -EndPoint 10.0.0.1 -Credentials (Get-Credential) -IgnoreCertificateError

# OPTIONAL -- Used to illustrate all of the volume snapshots.
# Get all the volume snapshots, this will include PGroups. 
Get-PfaAllVolumeSnapshots -Array $f | ft -a

# Pick a specific Pgroup snapshot. Name of snapshot is FLASHARRAYNAME:PGROUPNAME.SNAPSHOT_NAME
$PgroupSnapSource = Get-PfaVolumeSnapshots -Array $f -volumename 'solutions-lab-bfs-405-c09-20:z-nightly-replica-to-PureTEC.157.arvnd-Boot-Lun-05'

# Create a volume from the Pgroup source.
New-PfaVolume -Array $f -Source $PgroupSnapSource.name -VolumeName 'barkz-test'

# Validate the volume has been created.
Get-PfaVolume -Array $f -Name 'barkz-test'

Output example:

source                                   serial                   created              name                                                                                        size
------                                   ------                   -------              ----                                                                                        ----                                       161061273600
old-Mike-Bootlun-04-2016tp5              73E940225A2A52BB0002CEF0 2020-08-04T23:47:25Z old-Mike-Bootlun-04-2016tp5.Mike-Bootlun-Rep                                        161061273600 
.......LOTS OF SNAPSHOTS......
Barkz-Bootlun-03-WS2016-DC-GUI-3         73E940225A2A52BB0003D19D 2020-10-19T17:39:00Z z-nightly-replica-to-PureTEC.157.Barkz-Bootlun-03-WS2016-DC-GUI-3                   161061273600
Barkz-Bootlun-04-WS2016-DC-GUI-4         73E940225A2A52BB0003D19E 2020-10-19T17:39:00Z z-nightly-replica-to-PureTEC.157.Barkz-Bootlun-04-WS2016-DC-GUI-4                   161061273600
Barkz-Bootlun-02-WS2016-DC-GUI-2         73E940225A2A52BB0003D19F 2020-10-19T17:39:00Z z-nightly-replica-to-PureTEC.157.Barkz-Bootlun-02-WS2016-DC-GUI-2                   161061273600
Barkz-Bootlun-05-WS2016-DC-GUI-5         73E940225A2A52BB0003D1A0 2020-10-19T17:39:00Z z-nightly-replica-to-PureTEC.157.Barkz-Bootlun-05-WS2016-DC-GUI-5                   161061273600

source  : arvnd-Boot-Lun-05
serial  : 73E940225A2A52BB0003D1A7
created : 2020-10-19T17:39:00Z
name    : barkz-test2
size    : 75161927680

name           : barkz-test2
created        : 2020-10-19T17:39:00Z
source         : arvnd-Boot-Lun-05
time_remaining : 
serial         : 73E940225A2A52BB0003D1A7
size           : 75161927680

Renaming a Volume

Renaming a volume can be accomplished using the Rename-PfaVolumeOrSnapshot 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 SDK-Sample-5 volume is renamed to SDK-Rename-5. We use the Get-PfaVolumes cmdlet again to show all of the volumes like 'SDK-*'.

PS C:\> Rename-PfaVolumeOrSnapshot -Array $FlashArray -NewName 'SDK-Rename-5' -Name 'SDK-Sample-5'
name
----
SDK-Rename-5

PS C:\> Get-PfaVolumes -Array $FlashArray | Where-Object { $_.name -like 'SDK-*' } | Format-Table -AutoSize

source serial                   created              name                  size
------ ------                   -------              ----                  ----
       95DAA3D006E43D8F0004B467 2016-11-01T21:30:47Z SDK-Sample    536870912000
       95DAA3D006E43D8F0004B468 2016-11-01T21:41:16Z SDK-Sample-1     262144000
       95DAA3D006E43D8F0004B469 2016-11-01T21:41:17Z SDK-Sample-2     262144000
       95DAA3D006E43D8F0004B46A 2016-11-01T21:41:17Z SDK-Sample-3     262144000
       95DAA3D006E43D8F0004B46B 2016-11-01T21:41:17Z SDK-Sample-4     262144000
       95DAA3D006E43D8F0004B46C 2016-11-01T21:41:17Z SDK-Rename-5     262144000
       95DAA3D006E43D8F0004B46D 2016-11-01T21:41:17Z SDK-Sample-6     262144000
       95DAA3D006E43D8F0004B46E 2016-11-01T21:41:17Z SDK-Sample-7     262144000
       95DAA3D006E43D8F0004B46F 2016-11-01T21:41:17Z SDK-Sample-8     262144000
       95DAA3D006E43D8F0004B470 2016-11-01T21:41:17Z SDK-Sample-9     262144000
       95DAA3D006E43D8F0004B471 2016-11-01T21:41:18Z SDK-Sample-10    262144000

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 & I/O Metrics

There are a few PowerShell SDK cmdlets that provide volume metric information that can be useful in reporting scenarios.

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-PfaArraySpaceMetrics.

  • Get-PfaAllVolumeIOMetrics
  • Get-PfaAllVolumeIOMetricsAverage
  • Get-PfaAllVolumeIOMetricsTotal
  • Get-PfaAllVolumeSpaceMetrics
  • Get-PfaAllVolumeSpaceMetricsByTimeRange
  • Get-PfaVolumeIOMetrics
  • Get-PfaVolumeIOMetricsAverage
  • Get-PfaVolumeIOMetricsByTimeRange
  • Get-PfaVolumeSpaceMetrics
  • Get-PfaVolumeSpaceMetricsByTimeRange

Below is an example of using the Get-PfaVolumeSpaceMetrics for an individual volume which shows details related to space reporting (snapshots, data reduction, thin provisioning, total reduction).

PS C:\> Get-PfaVolumeSpaceMetrics -Array $FlashArray -VolumeName 'TPCE-FlatFiles-Dataset'

total             : 745852677691
name              : TPCE-FlatFiles-Dataset
system            :
snapshots         : 0
volumes           : 745852677691
data_reduction    : 3.122348960160198
size              : 4398046511104
shared_space      :
thin_provisioning : 0.47048936784267426
total_reduction   : 5.896669057312716

Below is an example of using the Get-PfaVolumeIOMetrics for an individual volume which shows details related to I/O reporting (reads, writes). For detailed information on how to calculate and intepret the different properties, read Calculating Block Size with the PowerShell SDK.

PS C:\> Get-PfaVolumeIOMetrics -Array $FlashArray -VolumeName 'Apps-CSV-1'
writes_per_sec    : 85
name              : Apps-CSV-1
usec_per_write_op : 17258
output_per_sec    : 0
reads_per_sec     : 0
input_per_sec     : 83962342
time              : 2016-11-01T21:59:54Z
usec_per_read_op  : 0