Run PowerShell Scripts in Virtual Machine ManagerBy Marco Shaw
There are a few products that have 100% Windows PowerShell coverage. The first server product to come from Microsoft that fully supported Windows PowerShell was Exchange 2007.
Unlike some other Microsoft server products, you could consider Windows PowerShell as a big driver in how the management and administration of Exchange 2007 was defined. Basically, Windows PowerShell was the focus of how Exchange would be managed and administered with a graphical user interface layered on top. I define this as a “tightly-integrated” product when it comes to Windows PowerShell support.
Products Integrating with PowerShell
Another product tightly-integrated with PowerShell is Microsoft Virtual Machine Manager which is part of the System Center Suite. Microsoft first came out with Virtual Machine Manager 2007 also. This was yet another Microsoft server product with full Windows PowerShell support and a graphical user interface basically layered on top of that.
I’m sure back in 2007, some people might have started to say, “This won’t last, Windows PowerShell will be gone in the next release,” but Windows PowerShell remains in these products even today. Both Exchange 2013 and Virtual Machine Manager 2012 SP1 have been released in the last few months, and still follow 100% Windows PowerShell support for managing and administering the product.
I think this provides a strong message from Microsoft. They think PowerShell is enterprise-class, and they can prove it. After all, these products are some of their most important ones (or big sellers), and people are using this “build it on Windows PowerShell first” methodology.
I had high hopes for the other members of Microsoft’s System Center Suite, I was slightly disappointed when I began seeing some of the product betas, but there are some definite improvements. If you look at Data Protection Manager, Operations Manager, Configuration Manager, Service Manager and App Controller, they all provide some level of Windows PowerShell support. I consider all of these as “loosely-integrated” products because the Windows PowerShell support seemed like an after-thought: Windows PowerShell is wrapped around existing APIs or an SDK, and does not provide all of the functions or tasks that can be done in the product’s graphical user interface. Nonetheless, the Windows PowerShell support they do provide is a definite time saver for various tasks including ad-hoc reporting.
Here, I’m just going to provide a simple example, but the possibilities are limitless. For example, I’m going to use Microsoft Virtual Machine Manager 2012 SP1 running on Server 2012 and go through the process of adding another Microsoft Hyper-V host to my server fabric.
How To Add a Hyper-V Host Using PowerShell
When you click on the “View Script” button, Notepad will open up and display the Windows PowerShell script that would be run. It was actually generated by the options chosen while going through the wizard:
I’ve edited the script simply so it fits a bit better, but one can see the power of the automation tool right in front of us! We can copy and paste this Windows PowerShell code into a console or an editor and create our own automation scripts for all kinds of tasks.
Remember, you’re saving time
Imagine needing to do something complicated and time-consuming such as using the new features, like network virtualization. Now, you can go through the process in production or in a lab environment, and take the Windows PowerShell scripts with you and easily automate tasks that were once maybe error-prone or just too time consuming.
That’s what Windows PowerShell is all about to me: Giving me the time to work on more important stuff, while automating everything else that doesn’t really need my full attention anymore.
The new training course on using VMM and Microsoft cloud, Configuring & Deploying a Private Cloud, doesn’t go into the specific details of using Windows PowerShell, but you can really become a DevOps ninja by learning PowerShell Fundamentals and weaving them in with the rest of your skills.
About the Author
Marco Shaw is an IT consultant working in Canada. He has been working in the IT industry for over 12 years. He was awarded the Microsoft MVP award for his contributions to the Windows PowerShell community for 5 consecutive years (2007-2011). He has co-authored a book on Windows PowerShell, contributed to Microsoft Press and Microsoft TechNet magazine, and also contributed chapters for other books such as Microsoft System Center Operations Manager and Microsoft SQL Server. He has spoken at Microsoft TechDays in Canada and at TechMentor in the United States. He currently holds the GIAC GSEC and RHCE certifications, and is actively working on others.
- What’s New in System Center Virtual Machine Manager 2008 R2 SP1
- Microsoft System Center Virtual Machine Manager (SCVMM 70-403) Exam Guide
- Windows PowerShell Conspiracy Theory?
- How To Test PowerShell Scripts With WhatIf
- Why You Can’t Afford to Ignore PowerShell
- Install Windows 8 in a Virtual Machine
- Video: Coordinate Your Scripts with Workflow in PowerShell v3
- Video: Give Your PowerShell Scripts A Modular Home
- Active Directory PowerShell Scripts Management Tool For Admins
- VMware — The Virtual Machine in Action