Posted by: Texiwill
Edward L. Haletky, ESX, Expect, Powershell, SSH, Texiwill, VMware
I have had several major issues with PowerShell (and still do), but that was mainly due to lack of cmdlets rather than lack of PowerShell functionality. So am I now one of the converted, given VMware’s integration with PowerShell? Yes and no.
Yes, because to me, PowerShell is just another scripting language.
No, because I want a scripting language that works well on all operating systems. (People will suggest Java, but that is another blog post.)
I wrote a Perl application that would log in to an ESX host, run an assessment of its configuration and from there aid me in judging the security of the host and some smaller parts of the virtual environment. Since it was written in Perl, it would be hard to get people to use excepting myself and other Perl users. This breed is found mostly within the Linux world; many VMware infrastructure administrators may not understand Perl well as it comes with a learning curve.
So I went looking at various other tools and discovered PowerGUI. PowerGUI is a great tool that has PowerPacks of prewritten PowerShell cmdlets that can run within the GUI.
There is a PowerPack for the VMware Infrastructure Toolkit, Hyper-V and Xen. The idea is to present a graphical interface for PowerShell cmdlets. This is just the interface I wanted for my tool, something I could plug into with ease to present the information in a way my users would easily understand with very little fuss. For them, it just has to work easily.
Unfortunately, PowerShell did not have the major facility I needed to make this work. It does not natively support secure shell and Expect functionality. Expect functionality allows a script to wait for predetermined output from a log-in session (or any other session) that often requires a password . Expect is a very valuable addition to any Linux programmers toolbox.
After posting my questions to the PowerShell channel on irc.freenode.net, I received some answers to my simple PowerShell programming questions. I also used Google searches to find how specific objects worked within PowerShell versus pre-existing cmdlets. Jaykul, a helpful participant on the irc channel, went even further to assist me by developing a set of SSH routines using the SharpSSH client written in .NET that actually has embedded Expect functionality. This type of assistance within a scripting community is outstanding. It shows that the backers really want PowerShell to be a success, and that Powershell can make use of any .NET library on a system.
This, combined with help from PowerGUI guru Scott Herold, will allow me to plug my tool into the PowerPack for VMware Virtualization as an action that can run on each ESX host or cluster as needed. This also implies I can worry about the guts of the code and leave the UI to someone else entirely.
After combining PowerGUI, the VMware Infrastructure Toolkit PowerPack and Jaykul’s Scritable SSH cmdlets I was off and running. My tool works for me and should be easy to understand for others, meaning it will work without tweaking and very few downloads, namely just As in it JUST WORKS with no twiddling and very few downloads, namely PowerShell and perhaps PowerGUI.
So as a long time Linux-centric developer, I have finally found a scripting language for Windows that works well. It is missing functionality that I am used to, but the community is extremely active and very helpful. For additional help, check out the Get Scripting Powershell podcast .
There are great scripts for the PowerShell version of the VMware Infrastructure Toolkit, and the list is growing daily. Be sure to bookmark Alan Renouf’s vDiagram script and his blog Virtu-AI. You’ll find many blog posts on PowerShell tools and links to useful scripts.
Now if they could make PowerShell run on Linux and Mac systems!