By now most of us have got a handle on this "virtualization fad" that swept through our data centers and changed the way we deploy applications. We've done our homework and now can deploy virtual machines from templates, clone existing VMs and utilize snapshot technologies to test and integrate patches and updates. Virtualization brought many benefits to companies, and due to that we've seen environments grow to a vast amount of virtual servers and hosts. Now this isn't so much of a bad thing, but the problem being, once we begin to grow we start to see monotonous, repetitive tasks related to reporting, provisioning and updating various configuration inside our environment.
This is where automation comes into play. There is a slew of orchestration and automation applications on the market today that help solve the problems in our data centers – and they all do a great job at doing so. For a lot of people who reside within the comfort of Windows every day, PowerShell seems like a natural progression for those looking to automate portions of their infrastructure, with PowerCLI being the product of choice for managing your vSphere environment. So if you are looking to get started with PowerShell, or more specifically PowerCLI, below are several resources that you might want to check out to help make your transition easier. Not only are they super helpful, but they are very easy to get approved by your CFO.
PowerGUI, which is developed by Quest Software (now part of Dell), is basically a GUI that has been built around PowerShell to provide more visibility as well as additional functionality when developing PowerShell scripts. PowerGUI gives us some essential features that can definitely help us when creating and authoring our PowerShell scripts.
One useful part of PowerGUI is code snippets. Code snippets are blocks of re-usable code that we can easily insert into our scripts while you are writing them. Think of scenarios where you might find yourself repetitively typing similar lines in your script. For example, declaring functions is a prime target to develop a code snippet around.
Next is what PowerGUI calls the variable explorer. Variable explorer allows you to expand and look inside the local variables that you use within our scripts. Ever find yourself wondering which property or method you need to use for a certain object? Variable explorer will allow you to dynamically view those properties, along with their corresponding values all within the same interface that you are authoring our script in. Variable explorer can be a true timesaver.
Next we look at PowerPack extensions. These PowerPacks essentially give you a graphical representation of their respective application and can literally write the scripts for us using nothing but a mouse. For instance, using the VMware PowerPack you have the ability to browse through your VMs and hosts in a tree-type interface and generate different scripts to report on and manage your environment. Aside from vSphere, you can also find extensions focused around Active Directory, SQL, Sharepoint and more.
Lastly, but certainly not least we have tab completion and syntax highlighting. Although this isn't a huge feature compared to the others, any developer will most definitely appreciate it. Aside from tab completion on cmdlets, PowerGUI makes it easy for you to find just what parameter you are looking to reference by presenting us with an auto suggest tab completion. On the highlighting side, PowerGUI will highlight similar type syntax to make your scripts easier to read and different areas easier to identify.
The shear fact that PowerGUI is available for the low price of free is definitely an excuse to go and check it out.
Admin Script Editor
Most of the PowerShell scripts written are simply text based and executed from within the PowerShell console. That said, there are times where I wish I could wrap a GUI around a few of my scripts to help when sharing the script with others that may not be so "command line" savvy.
Creating GUIs in PowerShell is not for the faint of heart – often it results hundreds of lines of code with the need to specify x and y axis values of where the controls will be placed on the screen. After you, you have the daunting task of adding event handlers and actions on the controls. Thankfully, there is an application that does this all for us, all in a nice drag and drop interface. That application is called Admin Script Editor (ASE).
The history of ASE is certainly unique. It used to be a paid and fully supported script editing application, yet when the influx of other editors hit the market these guys decided to close up shop and release the final version for free. ASE, like PowerGUI, is also a script editor and developer environment, but I tend to use it solely for the use of creating GUI wrappers and forms around my PowerShell scripts. It has a unique drag and drop interface that allows you to easily design forms containing different controls like textboxes, dropdown combo boxes, calendar date pickers and more. It also creates the functions for the click and change events on buttons and inputs among other things.
Keep in mind, ASE is not officially supported and only community supported. But I haven't had the need to engage in any support of the application as of yet. Plus, it's free.
The PowerCLI community site on VMware's website is one of the most resourceful sites for all that is PowerCLI. This is where you can find all of the links to the PowerCLI documentation, the bits to download as well as ask questions on the discussion forum. I can tell you from firsthand experience that I've never had a question that I've asked go unanswered inside of this forum, and it's not uncommon to have replies to your inquiries within the same day of asking. Aside from break/fix and 'how to' information, the forum also contains a documents section which includes over 100 different scripts that both VMware employees as well as partners and customers have written and are available for download. You should be able to find whatever you are looking for on the PowerCLI community.
Whether it be Google or a different search engine you prefer, it can help. Although Google isn't the actual PowerCLI resource, it is the indexer and gateway that leads you to the millions of scripts that are out on the internet sitting on forums, blogs, githubs and websites everywhere. PowerShell and PowerCLI have the benefit of being easily readable, which in turn makes them easily understandable but more importantly editable. Before I begin writing any script I always look to see if there is something familiar and nines times out of 10 there is a script that has already been written that does exactly what I need it to, with a few minor tweaks.
These are certainly not the only free resources out there to help you with your PowerCLI journey but are simply the ones I find myself accessing the most.