PowerWF News, Tutorials, and more...

Get the latest tips and tricks directly from the PowerWF development team. Find out about new releases and upcoming features.


Seamless Automation

From the Desktop to the Data Center

The PowerWF family of products are easy enough for desktop and departmental automation, yet powerful and scalable enough for the Data Center. PowerWF compliments Opalis and other RBA solutions, lets you leverage your workforce and preserves your investment as your automation needs grow.


Special - 20% Discount


In conjunction with our recently announced Silver Award from Windows IT Magazine we would like to offer our customers an opportunity to save 20% off any Devfarm product purchase through the end of the year. This includes all PowerWF products as well as Devfarm's new PowerVI product!

PowerVI

vSphere Automation fueled by PowerShell


Designed for the VMware Administrator, PowerVI eases the automation of vSphere infrastructures. PowerVI includes over 100 PowerShell automation scripts that simplify everyday VMware administration tasks and PowerVI makes it easy to author new scripts.
October 12, 2009

SAMPLE WORKFLOW: Virtual Machine Snapshot Age

VMware provides a relatively easy way to script virtual machine management using PowerShell with PowerCLI.  Unfortunately there is still a significant learning curve for someone with minimal PowerShell experience; not realizing a connection to the virtual center or ESX host is required before executing other commands, or that failure to close that connection in a script leaves the connection open indefinitely can be very frustrating.

Fortunately PowerWF simplifies this process significantly.     One problem VMware administrators face is finding old virtual machines snapshots that are wasting storage space.  The following example takes advantage of both PowerShell and PowerCLI to find outdated snapshots and email the results.  To begin, create a new workflow project named, “SnapshotAge”.

  1. To begin, create a new workflow project named, “SnapshotAge”.
  2. In many cases, a quick search of the web will yields a PowerCLI/PowerShell script to do most of the tasks in a workflow.  The following script is one such example:

    Get-VM * | Get-Snapshot | Select VM, Created, Name, Description

  3. If the PowerShell console is not already enabled, use the view tab on the ribbon bar to enable it.
    Enable Powershell Shell
  4. Enter the PowerShell script into the PowerShell Console and click the Insert Script button
    PowerShell - Shell
  5. PowerWF automatically converts the PowerShell script into a PowerWF workflow.  A connectVIserver activity was not in the initial PowerShell script and should be added.  The exclamation point icon next to the activity indicates that one or more required properties  are not properly configured.  Select the connectVIServer1 activity and fill in the appropriate values for  the server (VirtualCenter or ESX Host), user, and password.
    PowerWF Workflow from PowerShell Script
  6. At this point, visualization can be added and the script tested.  The desired output for this example is an HTML table, so in the toolbox search, type “html”.  This will list all HTML related activities.  Drag the “toHTML” activity to the workflow canvass and drop at the bottom of the “runspaceSequence1” activity.
    PowerWF activity search
  7. Once the output is converted to HTML, it can be displayed using a web browser.  Click the   next to the search box to show all activity packs.  Drop the webBrowser activity from Visualization into the workflow below the “toHTML1” activity.
    PowerWF WebBrowser Activity
  8. Press the Start button in the ribbon bar to run the workflow.  In its current state, the workflow finds the snapshots for the virtual machines and displays them as an HTML table.
    PowerWF HTML Table
  9. The results would be more meaningful if the data was sorted based on the creation date and VM name so that the oldest  snapshots appeared at the top of the table. Typing “sort” in the search bar finds the “sortObject” activity.  Drop this in the pipelineSequence below the “selectObject1” activity.
    PowerWF Sort Object activity
  10. The sort object requires selecting one or more columns to sort on and the sort order (ascending or descending).  Add two sort properties, Created and VM.
    PowerWF Sort properties
  11. Press the Start button in the ribbon bar to run the workflow.  The output is now in a meaningful format.
    Sorted PowerWF HTML Table
  12. The “WebBrowser” activity can now be deleted and replaced with the “SendMailBySMTP”.  This activity can be found by typing “mail” in the search bar.  The “SendMailBySMTP” requires slightly more configuration than some other activities.  Set the mail server host, user,password and SMTP Port and EnableSSL if necessary.
    PowerWF SMTP options
  13. It is also necessary to configure who the email is to and from, and the subject of the email.  Set the “To” email address to the target recipient and the “From” email address as the user whose credentials are used to connect to the mail server.  The Subject should be set to something meaningful, such as “Virtual Machine Snapshot Age Summary”.
    PowerWF SMTP options
  14. The final steps are to set the “BodyHTML” property to True  to configure the output of the “toHTML1” activity as the Body of the email.  Click on the  button and expand the “connection Runspace1 – toHTML”1 and select “Output”  This will bind the output from the “toHTML1” activity to the “Body” of the “sendMailBySMTP1” activity.
    PowerWF binding output to SMTP message body
    Up to this point PowerWF connected the output from one step in the workflow to the input of the next item in the workflow.  The “sendMailBySMTP” activity is a little different because the upstream outputs could be used as the Subject, the Body, or even as a User or Password.
  15. Press the Start button in the ribbon bar to run the workflow.  If everything is configured correctly, an email with snapshot ages should be sent to the target recipient.
    PowerWF SMTP output


blog comments powered by Disqus