image_pdfimage_print

Recently I wrote a blog post on how to authenticate and connect to Pure1 via PowerShell. You can find that here:

https://www.codyhosterman.com/2019/01/using-the-pure1-rest-api-part-i-powershell/

But it is fairly involved, so I made it easier for you (and me) by writing a PowerShell module and posted in on the PowerShell Gallery.

https://www.powershellgallery.com/packages/Cody.PureStorage.Pure1/

 

This is fairly limited right now, so keep an eye on it as a I update it. Currently it has three cmdlets:

  • Get-PureOneArrays
  • New-PureOneRestConnection
  • New-PureOneRestOperation

As I add updates you can see them here:

https://www.codyhosterman.com/pure1-rest-api/pure1-powershell-module/

The command new-pureonerestconnection connects to Pure1 for you. All you need to do is pass it your application ID and your certificate.

I am pulling my certificate from the Windows certificate store:

Storing it in $certobj. You find more information on certificates here:

https://www.codyhosterman.com/2019/01/using-the-pure1-rest-api-part-i-powershell/

Then install/load the module with:

When I release new versions, just run:

Now pass your application ID and certificate into the connection cmdlet.

It does not return any value. Instead it stores the access token in a global variable: $Global:pureOneRestHeader. This makes things easier–you do not need to pass the authentication into subsequent commands. Very similar to have vCenter connections work in PowerCLI.

The second currently cmdlet is for retrieving arrays, Get-PureOneArrays.

If you run it with no parameters, it will return all of your arrays.

You can also add in an array ID, an array name, or array product (FlashArray or FlashBlade).

Or just ask for all of your FlashBlades:

Now there is a lot more information you can pull from Pure1 besides what you see above–I will work on adding more cmdlets. Array busy meter, performance, tags, volumes, file systems, snapshots, etc.

Until then, I create another cmdlet that allows you to run any REST operation called new-pureOneRestOperation. Uses the same authentication as above, but allows you to enter in a custom resource type (arrays, volumes, etc), a JSON body, and or custom queries or filters.

In the below case, I am adding a key/value tag to my array called sn1-420-a09-14. For how to format and what options you have, just look at our REST documentation.

https://support.purestorage.com/Pure1/Pure1_Manage/Pure1_Manage_-REST_API/Pure1_Manage-_REST_API__Reference

Enjoy!!