PowerCLI Core was developed by VMware Fling Labs as a way of enabling users of Linux, Mac and Docker to use the same PowerShell cmdlets that were previously only available on Windows. This means sysadmins can now have a multi-platform scripting language that lets them manage their VMware infrastructure from any operating system as it makes PowerShell scripts written for Windows portable to other operating systems without any changes being necessary to their scripts. PowerCLI Core was only released back in October 2016 so it's pretty new, and to introduce its capabilities to our VirtualizationAdmin.com readers I've asked Luc Dekens, a long time VMware vExpert and Microsoft MVP, to give us a brief walkthrough. PowerShell is Luc's tool of choice, and he's fascinated by all things automation and DevOps. Luc is also a regular speaker at conferences and his blog can be found here:
You can also follow Luc on Twitter (@LucD22) here:
Let's now listen and watch as Luc demonstrates describes the rationale and capabilities PowerCLI Core…
It's a brave new (open) world!
Since a picture tells more than a thousand words, what does the following tell you?
Let's have a closer look. That seems to be a terminal window on a Linux system. Ah wait, that 'uname' command will give us an indication where this is running.
Ok, it seems to be a recent Ubuntu 16.4 build. Nothing special about that.
But then the next command, 'powershell', that looks oddly out of place on a Linux system? Wasn't PowerShell this new scripting language from Microsoft for Windows systems?
Well, not anymore. On August 18, 2016, Microsoft announced that they open sourced the next PowerShell release. The new PowerShell v6 runs, not only on Windows platforms, but also on several Linux distributions and under Mac OS X:
The complete source of PowerShell 6 is published in a Github repository and open for community contributions.
All this can count as another proof of the "Under new management" sign we have been seeing on recent Microsoft announcements!
Not only did Microsoft open up PowerShell, they also took other companies along on their new path.
One of the early and successful adaptors of the Windows version of PowerShell was VMware. In 2007 they started with their VI Toolkit, a collection of PowerShell PSSnapins to automate the administration of their vSphere environment. And just recently they released VMware PowerCLI 6.5R1. A new version with a new product name, and all modules now.
But going back to the "open" world, on that same August 18, 2016, VMware also announced that they were joining the Microsoft initiative with a PowerCLI Core build.
Thus, you can now automate the management of your VMware products from new platforms like Linux and Mac OS X, but by still using your same PowerShell skills you developed on Windows platforms. You may have also seen a demonstration of this with Jeffrey Snover and Alan Renouf when PowerShell Core was announced.
To curb your enthusiasm a bit, note that PowerShell Core and PowerCLI Core are still "alpha" code. So don't even think of managing your production environments with these versions yet!
Since large companies normally don't have a habit of doing things for free, I wanted to delve a bit deeper into the reasoning why a company like VMware for example, joined this open initiative from Microsoft.
I had a short Q&A session with Alan Renouf, the Senior Product Line Manager for APIs, SDKs, CLIs at VMware.
Q: VMware has been one of the earliest third party adopters of PowerShell (since 2007). Did it take a lot of convincing to jump on the "open" wagon recently, i.e. PowerShell Core?
Alan: Did you know the reason PowerCLI (for Windows) started out was when VMware admins needed an easy way to disconnect CD-Rom drives on multiple virtual machines, boy it sure has grown since then! Since the initial use case and deciding to adopt PowerShell as a framework to provide automation and integration into VMware products to system administrators VMware has a great relationship with Microsoft, in fact we have been working with them for a long time now to make PowerShell Core a reality and of course PowerCLI Core followed shortly after, Microsoft needed early adopters to ensure they had the functionality in PowerShell Core for existing PowerShell providers to be able to move to the Core version with ease.
At VMware as you know we have no strict ties to an OS – we virtualize them all. Over time we have seen a rising popularity of Mac OS and Linux Desktop OS being used as well as clearly a multitude of different OS versions being virtualized and used as a server operating system. These OS users still needed the ability to automate and integrate with VMware products so moving to PowerCLI Core and enabling these users was a no brainer!
Now all our customer base can use the same command line tool, no matter what their OS. And have the benefits, of not only PowerCLI Core, but also the wealth of community information and years of scripts that have been made available to them.
Q: PowerShell Core is written for many platforms (Windows, Linux, Mac OS). Do you plan on making all PowerCLI functionality available on all the hosting platforms that PowerShell Core will be available on? Does this cause additional technical issues that need to be resolved?
Alan: When moving the cmdlets from PowerShell and .Net to PowerShell Core and .Net Core you do indeed need to make changes, that's why PowerCLI is not fully functional and available as a supported product day 1.
Not all the functionality was moved to .net core so first of all it's a case of making sure what you need is indeed there and if not what alternatives you can use, secondly not all the PowerShell functionality or cmdlets are there, so again you need to work out what you can no longer rely on and find a way to provide this. After these are completed you need to ensure you were not using any windows specific functionality. If you were then you need to try and make this generic, find a way that you can use something that is "cross platform" so that it can indeed be used on any OS.
In short, yes, we would love to support all OS versions PowerShell core has been made available on (and more, see VMware Photon) but clearly this takes time to finally move the entire product over.
Q: The PowerShell Core code is now "public" on GitHub. Is this something that might be in the future of PowerCLI? Is an "open" PowerCLI Core something that would be feasible? Do you see any gain in eventually opening (part of) the PowerCLI source code?
Alan: It's been a long-term vision of PowerCLI for a while now to open source the product and make it available in GitHub. This unfortunately is not as easy as flipping a switch, it requires a lot of changes to the way the product is designed, developed and tested and not to mention the legal discussions! Allowing others to contribute, see the code and how we achieve things is a good thing for the community but this will take more time, bear with me!
Q: At the last VMworld you announced a name change of the product, from vSphere PowerCLI to VMware PowerCLI. Would you mind explaining again what the idea behind that name change is? And does this have any impact on PowerCLI for PowerShell Core?
Alan: Since the original version of PowerCLI or as it was known then "VI Toolkit" it was focused on providing automation and integration of vSphere related products, more recently you will have seen it spread to other areas like SRM, vRealize Operations, vCloud Air, vCloud Director, Horizon View, Horizon Mirage and Workspace Environment Manager.
As you can see, this is no longer a vSphere only product, my vision is to provide a single interface to all VMware products allowing our customers to learn a CLI once and have it available cross product, cross platform to automate and integrate everything from VMware. As you can see, we are making moves in the right direction and our customers are seeming to be pleased with the direction we are headed!
Thanks Alan for this Q&A. Lots of exciting things ahead!!
To be continued
In Part 2 of this article we'll experience a first encounter with PowerCLI Core and include some scripting examples for you to play with.