Recently I wrote a blog post on how to authenticate and connect to Pure1 via PowerShell. You can find that here:
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:
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:
1 |
$CertObj = Get–ChildItem Cert:LocalMachinemy9A3F43947557B299FD9821B56719C635A6338A0F |
Storing it in $certobj. You find more information on certificates here:
Then install/load the module with:
1 2 |
install–module Cody.PureStorage.Pure1 import–module Cody.PureStorage.Pure1 |
When I release new versions, just run:
1 |
update–module Cody.PureStorage.Pure1 |
Now pass your application ID and certificate into the connection cmdlet.
1 |
New–PureOneRestConnection –certificate $CertObj –pureAppID “pure1:apikey:VIx9l8Do5W9tiYrL” |
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.
1 |
Get–PureOneArrays |
You can also add in an array ID, an array name, or array product (FlashArray or FlashBlade).
1 |
Get–PureOneArrays –arrayName “sn1-m50-b01-33” |
1 |
Get–PureOneArrays –arrayId “sn1-m50-b01-33” |
Or just ask for all of your FlashBlades:
1 |
Get–PureOneArrays –arrayProduct FlashBlade |
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.
1 2 |
New–PureOneRestOperation –restOperationType PUT –resourceType “arrays/tags/batch” –queryFilter “ ?resource_names=’sn1-420-a09-14′” –jsonBody ‘[{“key”:”test-tag”,”value”:”testcody-ps”}]’ |
Enjoy!!