***********UPDATE PLEASE REFER TO THE POST AT THIS LINK FOR UPDATED INFORMATION ON THIS SCRIPT***********************
Quick update. I have posted a new version of the PowerCLI UNMAP script that I maintain. I usually do not put a blog post out every time I update it, but there were enough changes here I think it was worth a quick note.
The biggest change is that fact that I have a new version of the script called unmapsdk that no longer makes direct REST calls to the FlashArray but instead uses the Pure Storage PowerShell SDK that is freely available for customers and partners here:
Huge thanks to my coworker Barkz for very quickly helping me convert the former script into a SDK based one. Because of the SDK, it is now much cleaner and simpler to understand than making direct REST calls with invoke-restmethod. I will be focusing all enhancements on that script version from now on most likely. I will keep both up on my GitHub though. They are in feature parity right now though (September 28th, 2015). Both versions have the following changes.
Most notably the script supports multiple FlashArrays present in the same vCenter. The script can now handle the configuration of multiple connections to different FlashArrays in the $flasharrays variable.
I used to just have a $purevip variable, but the way it was managed it could only hold one FlashArray and the connection management for the REST calls had the same issue. So now enter them into the $flasharrays variable as a hash table.
So if you have three FlashArrays and their IPs are the following:
192.168.1.120, 192.168.1.130 and 192.168.1.140
Enter them into line 35 like so:
$flasharrays = @("192.168.1.120","192.168.1.130","192.168.1.140")
If you just have one FlashArray it will look like:
$flasharrays = @("192.168.1.120")
Also, they still share the same user name and password in this script. I will add multi-password handling in the future if this comes up as a problem. So just enter the credentials once.
The REST API version is now using 1.4, so any FlashArray running Purity 4.1.x or later will be fine. You really should be running those code levels anyways.
To sum up, these are the requirements:
- (SDK version only) Pure Storage PowerShell SDK must be installed
- PowerShell 3.0 or later
- PowerCLI 6.0 Release 1 or later (5.5/5.8 is likely fine, but not tested with this script version)
- REST API 1.4 and later
- Purity 4.1 and later
- FlashArray 400 Series or //m
- vCenter 5.5 and later
- Each FlashArray datastore must be present to at least one ESXi version 5.5 or later host or it will not be reclaimed
Check it out!
Direct REST version:
https://github.com/codyhosterman/powercli/blob/master/unmap.ps1
Pure Storage PowerShell SDK version:
https://github.com/codyhosterman/powercli/blob/master/unmapsdk.ps1
Is there a way other than with the logs to see where the script is failing? The script worked perfect up until I left for Christmas break.
I do need to add better error handling into it, thats for sure. But currently besides the log there isn’t much of a better option to find out. What kind of failure are you running into?
We were able to figure it out – permission issue. I’m not sure why the service account I used worked well for 2-3 months and then randomly stopped on 1/5/2015.
Ah I think support pinged me on this. Good to hear things worked out, but strange to hear things changed suddenly. If you have any feedback on how I can improve this to help with this issue you had please let me know.
Thank you for your work on this. Im looking to implement this script with PowerActions, should I be able to copy and paste the unmap.ps1 script @ GitHub, into a PowerActions script, and it work correctly after changing the variables for our environment?
Thanks!
Sure thing! Yeah it should slide in pretty easily. Just need to alter some of the inputs (and remove a few connection lines). I have a post I did a while back around this with a simpler script and PowerActions
https://www.codyhosterman.com/2014/10/poweractions-the-powercli-plugin-for-the-vsphere-web-client-with-unmap/
I really need to update it though to take account for new UNMAP rules etc. But it gives the idea
Cody,
Yeah, I saw that post as well, which is why I asked the above. It seemed like there were some changes you had to make to be able to run it thru PowerActions. I’m a Linux Admin, but was asked to help out on this, so Ill see if I can figure out where and what changes I need to make to the unmap.ps1 script to get it to work in PowerActions.
Thanks!
If you don’t mind waiting I can do some of this work for you. Might be a week or so though. I’d be happy to help over email too. cody AT pure storage dot com