Manage Learn to apply best practices and optimize your operations.

Mixing PowerShell and VMware for potent possibilities

VMware provides its own tools for monitoring and other tasks, but what if you could automate those tasks to save yourself time?

As virtualization, cloud and automation continue to grow and mature, PowerShell will continue to be an important...

tool for admins.

Thinking back to my days spent supporting servers and VMware environments, I remember there was usually little time to breathe because there was always a fire to put out. I would look for ways to make life easier and more stable, and this often led to the use of scripts to accomplish repetitive tasks.

PowerShell is a helpful scripting language for Windows admins and VMware offers support via their PowerCLI offering. This was enough to get me interested in seeing if this might be useful.

Run a system health check

Over the years, I've worked with a number of customers, and the overwhelming majority of cases used vCenter to manage VMware environments. This was no surprise, because vCenter is required for much of the magic. The surprise was people were not investing in the VMware or third-party tools for managing performance and health; they were relying on vCenter's basic features. Other customers were taking steps to execute labor-intensive processes to keep tabs on the vSphere environment. Neither of these is very scalable or easy for admins.

This is where I would ask them if they had ever used PowerShell and VMware together. Some said they had while others said scripting wasn't something they were familiar with. The good news is there is plenty of helpful content in the community to help you get started, and one of my favorites has matured over time. This is vCheck from Alan Renouf.

The vCheck script is a framework that allows others to create plugins that can add specific functionality they would like to report on, but this does not mean you need to create your own plugins. There are already great scripts for vSphere, vCloud Director and several other applications so admins can get instant value out of the script. You can set vCheck to run on a scheduled basis and email the results each morning while enjoying your first cup of coffee. Find out more about vCheck and download it here.

Reduce the chance of manual errors

With PowerShell and VMware, you can execute a script consisting of individual commands that can configure different options on a host or group of hosts. If I need to create a new vSwitch on all hosts in a cluster, I could do this manually -- which takes 30 minutes or more and could possibly result in an error -- or I can use PowerShell to configure all of the hosts in the cluster at once and they will be identical. This is an excellent way to reduce the time needed to configure new hosts and update the configuration on existing hosts.

Reporting

The ability to query data in your VMware environment and capture that information is a valuable skill, but usually requires a paid tool or manual work. If you know how to use PowerShell, you can accomplish your tasks without wasting time doing them by hand. Let's look at an example to show what you can do with PowerShell.

Say you're working on a backup-related project and need a report that shows which VMs have Change Block Tracking (CBT) enabled and which ones do not. If you did this yourself it could take 10 minutes per VM, so in an average-sized environment this will consume a lot of your time. By using PowerShell, you can report on all the VMs with a single command.

With the following command, a list of all VMs in your vCenter will be returned with the status of CBT on each one:

Get-VM | Get-View | ` Sort Name | Select Name, ` @{N="ChangeTrackingStatus";E={$_.Config.ChangeTrackingEnabled}}

Automation and orchestration

I've laid some of the groundwork of what's possible with PowerShell and VMware. It's worth noting that many of DevOps tools and process can use PowerShell as a method to automate tasks. For example, vRealize Orchestrator -- formerly vCenter Orchestrator -- from VMware is a workflow tool for automation, but there is a PowerShell plugin that can be used to integrate PowerShell with their workflows, which allows for expanded features beyond the snippets that are included with Orchestrator and does not require someone to learn a language like Java.

Next Steps

What you should know about using vRealize Orchestrator and PowerShell together

12 PowerShell tips, tricks and helpful hints

How to manage virtual desktops with Windows PowerShell commands

This was last published in May 2015

Dig Deeper on VMware performance enhancements

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

Do you use VMware with PowerShell? What do you think of them together?
Cancel

-ADS BY GOOGLE

SearchServerVirtualization

SearchVirtualDesktop

SearchDataCenter

SearchCloudComputing

Close