Saturday, February 4, 2012

Host Profile update made easy with PowerCLI GUI

You don't usually associate Powershell with GUI. However, powershell is extremely .NET friendly.  You can build pretty impressive Windows GUI interface with it. But, it is not easy writing the GUI code line by line in Powershell. That is why I like to use Sapien Primary Forms. You can build GUI inteface using the graphic utility and it will write the powershell script for you.  How awesome is that?
Script below is one of the GUI interface script that I wrote.  It checks host profile in the cluster and applies the host profile on single ESX host at a time.  It does it by putting one non-compliant host in to maintenance  mode by evacuating the VMs using DRS and vMotion.  Once the host server is place in to maintenance mode, it applies assigned host profile and takes the server out of the maintenance mode once it is completed.  I hope to post more of my GUI scripts in the future.

You can grab my script from here.





2 comments:

  1. This is basic functionality I wish vSphere had. Thanks for spending the time to put it together, very appreciated!

    ReplyDelete
  2. Thanks. .NET GUI on Powershell still has long ways to go. The GUI freezes while the script is running behind it because it is not multi-threaded. I found the way to do it using Start-Job command but I found it to be buggy on Powershell 2.0.

    ReplyDelete