Windows PowerShell + Purity CLI = Invoke-PureVolSnap

@8arkz — June 20/17 — PowerShell Toolkit 0.1 implementing FlashRecover Snapshots for SQL Server.

I’ve been focusing on some automation scripts over the last week and have come up with a first generation (v0.1) script that shows yes Windows PowerShell and Pure technology can be combined for purposes of automation. Granted this isn’t a true PowerShell cmdlet implementation but gets the job done and who knows where this will go moving forward. I did stay with the basic principles of PowerShell Verbs for the script thinking in my mind that I’d like to implement this as a prototype cmdlet next.

The implementation has  two components (1) XML configuration file and (2) Invoke-PureVolSnap.ps1. The below XML configuration file controls what actions are performed on specific volumes, what snapshot suffix to use, what hosts to connect, etc. The following screenshot illustrates what type of output that will be shown in Windows PowerShell or the PowerShell_ISE.

Pure_Storage_Config.xml

Invoke-PureVolSnap.ps1

The most complicated element of this script is the use of DiskPart in conjunction with the core Windows implementation for disk activities like Get-Disk, Set-Disk, etc. The key is to enable PowerShell Remoting, the basic commands are:

Stay tuned for further updates and please let me know if there are questions, ideas, issues as it would be great to understand what functionality people are looking to implement.

  • q

    Looks good Barkz!
    Can you get the script to ask for the LUN on the server then have the script enumerate the data to build the xml file? Seems like a lot of pain to set up the xml file for each LUN.
    Can you just try your troubleshooting steps once and alert if something is wrong? Once you have ensured WinRM is set to automatic and powershell remoting is enabled set a bit in the registry?

    Keep it up!
    q

  • themicrosoftdude

    The approach I took with the XML file was to allow for customization by the end user in order to define their environment for automated processing. Eg. there is a SQL Server in production that needs to copied off for reporting purposes. The XML would allow for all the other hosts (Windows+SQL Server) to be defined then take the PowerShell plug in into Windows Task Scheduler, a runbook or other scheduling tool to do all the snapshots and connect to all the different hosts. The next part of the script I am just finishing up and will post is to then take all those new connected hosts and automate attaching databases, etc.

    The PowerShell remoting needs to be configured on the different hosts. For security reasons I suggest setting the TrustedHosts to accept only remote operations from approved systems.

    Good to hear from you Q!

  • Hi, i have reading out and i will definitely bookmarrk your site, just wanted to say i liked this article.