Pure1 1.0.8

PowerShell script for making RestAPI calls using PureStorage.Pure1 API Module.

https://github.com/PureStorage-OpenConnect/PureStorage.Pure1


Prerequisites

Install PureStorage.Pure1 API Module

Install-Module -Name PureStorage.Pure1 -scope currentuser

Create certificate and Api file

  1. Create a Certificate

    $cert = New-PureOneCertificate PSParentPath: Microsoft.PowerShell.Security\Certificate::CurrentUser\my Thumbprint Subject ---------- ------- E98504123F5B615AD6231237CA5F456C63FEA3C4 CN=PureOneCert

    This step creates initial certificate in Certificate Manager.

    By default it will expire in 1 year.

    Certificate is located in Certificate Manager (certmgr.msc) at folder Personal\Certificates & Intermediate Certificate Authories.

  2. Create a Public Key & Pure1 APIKEY

    $cert | Get-PureOnePublicKey -----BEGIN PUBLIC KEY----- MxxBIjANBgkqhkiG9w0BAQEFxxOCAQ8AMIIBCgKCAQEA9yEmTaOn5KswvY5e9OIQ6epN3AF -----END PUBLIC KEY-----

    Copy above public key into Pure1 API registration to generate an API Key.

    Choose 'ReadOnly'.

    Record the APIKEY: pure1:apikey:oKPyzppg123hM8Xx

    Test the apikey

    New-PureOneConnection -PureAppID pure1:apikey:oKPyzppg123hM8Xx

    Token is stored in $Global:PureOneConnections and expires after 10 hours.

    Create a file named, PureOneCert.api where the first line is the content of the apikey.

    In this example the first line of the file should equal: pure1:apikey:oKPyzppg123hM8Xx

  3. Export PureOneCert certificate to the file, PureOneCert.pfx

    There are 2 methods available to exporting the certificate.

    Best Export Method: Get-PureOneCertificate

    Get-PureOneCertificate -Export Please enter a certificate export password: ******

    Other Export Method: Certificate Manager (certmgr.msc)

    Export the certificate, PureOneCert as file name, PureOneCert.pfx.

    Update the file, PureOneCert.api

    Add second line to the file, PureOneCert.api containing the password of the exported certificate file.

    Putting a password in a text file is usually not a recommended practice. In this instance, the certificate was created as ReadOnly so I'm not too worried about this risk.

    The only time a password in needed is when importing the certificate for the first time and thereafter the password is not needed. If you update the second line of the file to 'nopassword', then there will be a prompt to enter the password when the certificate is imported.


Pure1 script installation

Copy the files, Pure1.ps1, PureOneCert.pfx, and PureOneCert.api to your desired folder location.


General Syntax

Pure1 <action> <filter>

List PureStorage arrays

Pure1 List pure

Lists the PureStorage arrays in Pure1 with array names matching 'pure'.


List PureStorage array volume(s)

Pure1 volumes

Prompts for a specific Pure Storage array name and displays each volume name and size in (TB).


List Snapshots

Pure1 SnapShots

List snapshots and source volumes for all Pure Storage arrays.


List PureStorage array load metric

Pure1 Load pure

Displays current load value and Max/Min load value for Pure Storage arrays matching the filter 'pure'.


List PureStorage array Network attributes

Pure1 Network pure001

List the network interfaces and associated attributes for PureStorage array, pure001.


List PureStorage array with specific tag value

Pure1 Tag Environment.Production

List all Pure Storage arrays that have an Environment tag with a value of 'Production'.


List Metric Details

Pure1 MetricDetails

List all available metrics

Pure1 MetricDetails array

List of metrics filtered by 'array'


List PureStorage array metric

Pure1 Metric Show Pure Storage array metric Enter Pure Storage array name:pure001 Enter Pure Storage metric name:array_total_load PureArray array_total_load Max array_total_load Min array_total_load --------- ---------------- -------------------- -------------------- pure001 57.9 90.702 27.236

List PureStorage array Capacity metrics

Pure1 Capacity Show PureStorage Capacity Metrics in TB Enter PureStorage array name: pure001 PureArray PercentFull Capacity Used Volume Shared Snapshot System --------- ----------- -------- ---- ------ ------ -------- ------ pure001 69.27 120.57 83.52 64.13 18.73 0.66 0