Home > Blogs > VMware PowerCLI Blog > Author Archives: Kyle Ruddy

Author Archives: Kyle Ruddy

Kyle Ruddy

About Kyle Ruddy

Kyle Ruddy is a Senior Technical Marketing Architect working for VMware R&D in the Cloud Platform Business Unit. Kyle currently focuses on vSphere and VMware Cloud on AWS automation and the associated automation frameworks including all things API, CLI, and SDK. Kyle is also a Microsoft MVP and long-term vExpert whom can be found blogging on VMware blogs, http://blogs.vmware.com/vSphere and http://blogs.vmware.com/PowerCLI, and his personal blog, https://www.kmruddy.com. His Twitter: @kmruddy

Discovering VMs with Specific VMware Tools Versions

A recent knowledge base (KB) article was released regarding an issue impacting a specific version of VMware Tools. The KB in question is 57796, which describes the possibility of a guest level network connectivity issues or even a purple diagnostic screen (PSOD).

Before getting to the discovery process, I want to cover some of the specifics for this KB. I do this because we’re going to need to be aware of these as we build out our one-liners and the subsequent reporting script.

The issue in the KB may be found when combined with the following:

  • VMware Tools version 10.3.0
  • ESXi 6.5 Hosts
  • VM Hardware 13
  • Windows Server 2012 or newer -OR- Windows 8 or newer

Now that we know what we’re looking for, lets cover some methods we’ll be using to make this easier.

Properties, Hash Tables, and More

Since we’re going to be focused on VMs, we’ll be making use of the Get-VM cmdlet. However, the information we need isn’t available as part of the cmdlet’s default response. We’ll need to choose specific VM properties to display.

Discovering those properties can be done in a couple different ways. If we just want to find out what properties are available and how they’re defined, we can use the Get-Member cmdlet. If we want to find out the values for all of those properties, we can use the Format-Table cmdlet. Both of these cmdlets can be used in the same way, by using the Get-VM cmdlet and passing the output to the desired cmdlet with a pipeline.

Example Code:
Show Properties for Virtual Machine Objects

In this case we’re going to be referencing the ‘Name’ property and an additional property which is available as part of the listed ‘Guest’ property, which is actually defined as an object. The property we’re looking for in the Guest object is named ‘ToolsVersion’.

We can output these specific properties using the Select-Object cmdlet. In order to properly display the ‘ToolsVersion’ property, we’ll be using a hash table to create a calculated property. The hash table is created with an ampersand and curly brackets. We can establish the calculated property with ‘name’ and ‘expression’ values.

Listing VMs and their VM Tools Versions

First things first, let’s figure out how to display our VMs’ names and their VM Tools version using the Select-Object cmdlet and a calculated property for the Tools Version.

Example Code:

PowerCLI - Get VMs and list Name and Tools Version

Listing VM Specific Information from the KB

In the example above, we can see there’s one particular VM which may be impacted by the KB. So, the next step is to obtain the rest of the information about each of the VMs.

We’ve already obtained the VM’s name and VMware Tools version properties. Now we need to figure out the ESXi host version, VM Hardware version, and what OS is in use.

The ESXi host version can be found using the VMHost property. This property returns the full ESXi host object. Since we’re working with the full object, we can return the ‘Version’ property by way of the calculated property method we used previously.

The VM Hardware version can be found by referencing the ‘HardwareVersion’ property.

The last property we’re interested in is the OS type. This too is available as a sub-property to ‘Guest’. There’s a couple to choose from, but for this example we’ll start with the ‘GuestFamily’ property.

Example Code:

Obtain requisite information for each VM per the KB

Listing Only Applicable VMs

For our last example, let’s take this process a step further and display only the susceptible VMs.

We’ll do this with the Where-Object cmdlet. We’ll use this cmdlet, in combination with a script block, to validate that each of those properties match those items listed in the KB.

We’ll be validating the following properties:

ToolsVersion 10.3.0
VMHostVersion 6.5.0
HardwareVersion vmx-13
GuestFamily windowsGuest

Example Code:

View only potentially impacted VMs

Summary

Knowledge Base article 57796 details a specific issue which has the potential to impact environments. We can use PowerCLI to easily poll our environment to obtain, and even isolate, the specific VMs which may be impacted.

Let us know in the comments how you’re building on what’s available here to create reports and even remediations!

Introducing Code Capture

I am extremely excited to announce a new feature that’s been added to the vSphere HTML5 Web Client Fling. This new feature is called Code Capture. While the name might not sound familiar, hopefully you’re already acquainted with its predecessor – Onyx, which is currently the most requested feature on the PowerCLI Feature Requests site!

PowerCLI Feature Requests Site - Most Popular

Code Capture gives you the ability to take actions you’ve completed in the vSphere Client and outputs usable code. Once you have the vSphere HTML5 Web Client Fling installed, it’s just as simple as hitting the red ‘record’ button on the top menu, performing your activities, then hitting the red ‘stop’ button. At this point, you’ll be taken to the Code Capture section where you can browse your code and even copy or download the code as well!

Before jumping to download the fling, we should discuss what a VMware Fling really is. Flings are projects that are built by our engineers and made available for general consumption. These flings are distributed under the Technical Preview License and, therefore, are recommended to not be run on production environments. This also means there is no ability to open a VMware support request. However, you can open a bug against the fling itself using the ‘Bugs‘ tab. Also, I would like to point out the ‘Comments‘ tab where you can submit feedback. We would greatly appreciate any and all feedback you have!

Now, let’s checkout Code Capture!

Code Capture in Action

Code Capture In Action

Now let’s take a more in-depth look.

Code Capture Output

In the example above, we can see that we are shutting down a system by the name of ‘app01’. Once we click on the ‘stop’ button, it shows us the PowerCLI.NET code. This is important because, at first glance, the output may not be quite as you expect.

For example, you may have expected to see a command like Shutdown-VMGuest -Name app01 Instead, we saw low-level PowerCLI calls. Walking through the code, it created a VirtualMachine object, which referenced the app01 VM by MoRef, followed by the usage of a method named ‘ShutdownGuest’ that is called directly against the VM object. More information about this specific method: ShutdownGuest()

Code Output:

It’s worth noting, at this point in time, all of the returned code is going to be in this manner. There are on-going investigations to add the translation from this code into high-level PowerCLI cmdlets. If this type of conversion is important to you, please add a comment to the following PowerCLI Feature Request: Onyx support for HTML5 and REST APIs

Using the Output

If I were to power on the app01 VM, I could then use the code in a PowerShell session (where I’m already connected to the vCenter Server) to shutdown the app01 system. To make this easier, Code Capture includes a ‘Copy’ button which easily copies the entirety of the code to our clipboard. We can now paste this into our PowerShell session to accomplish the task!

Example:
Code Capture Copy Paste Output

Another option to extract the code from our browser is with the ‘Download’ button. Clicking ‘Download’ will, depending on your browser configuration, save a file named ‘power-cli-script.ps1’ to your Downloads folder. We can then call that file just like any script from our PowerShell session to accomplish the action.

Example:
Code Capture Using Downloaded Script

Summary

The next generation of Onyx is here and it’s called Code Capture, which is only available in the vSphere HTML5 Web Client Fling! Using the start and stop button on the main menu bar, Code Capture allows you to take your actions in the vSphere Client and output them to PowerCLI code. The code output can also easily be copied and/or downloaded from your browser session using the dedicated buttons in the Code Capture area.

Get started by heading over to the vSphere HTML5 Web Client Fling page and downloading the latest version today!

New Release: PowerCLI 10.2.0

It’s new release day! Even though we’re counting down the days to VMworld, we still have a fresh version for you with PowerCLI 10.2.0!

Speaking of counting, this marks the 4th release of PowerCLI this year. I remember when getting 2 updates in a single year was a major event, much less four! A big shout-out to the PowerCLI engineering team for all the work that’s been done to make this process faster and easier. If you’d like to know more details, VMworld session DEV3504BU will take an in-depth look at the PowerCLI development process. It’s a session I’m super excited for!

On to the updates!

PowerCLI 10.2.0 Updates

PowerCLI 10.2.0 comes with the following updates:

  • Support for NSX-T 2.2
  • Deprecation of the PCloud module, so look for this module to be removed in the future
  • Update to Get-VIEvent to resolve the issue when receiving: Error in deserializing body of reply message for operation ‘RetrieveProperties’

For more information on changes made in VMware PowerCLI 10.2.0, including improvements, security enhancements, and deprecated features, see the VMware PowerCLI Change Log. For more information on specific product features, see the VMware PowerCLI 10.2.0 User’s Guide. For more information on specific cmdlets, see the VMware PowerCLI 10.2.0 Cmdlet Reference.

Remember, updating your PowerCLI modules is now as easy as ‘Update-Module VMware.PowerCLI’.

Update-Module VMware.PowerCLI

PowerCLI at VMworld US 2018

VMworld 2018 Banner

It’s August and that means VMworld is right around the corner! Last year, we had an unprecedented amount of PowerCLI and automation-based sessions and that trend has continued this year! There are more sessions, a re-vamped PowerCLI Hands-On-Lab, not one but two expert-led PowerCLI Hands-On Lab time slots, a Hackathon training session, and there are more vBrownBag & VMware {code} Power sessions than I can count! If you haven’t already registered, the time is quickly ticking away!

Make sure to add the following sessions to your schedule and catch up with the PowerCLI team and the amazing PowerCLI community members!

Sessions

Session: DEV3504BU – Development at VMware: A Look at How PowerCLI Has Evolved Over the Years
Date: Monday, Aug 27, 4:00 p.m. – 5:00 p.m.
Speakers: Kamen Nikolov & Kyle Ruddy
Kamen and Kyle will give attendees a behind the scenes look into the PowerCLI development process and the many ways PowerCLI has evolved over the last 10+ years.

Session: VIN2661BU – Start Automating All The Things with PowerCLI
Date: Tuesday, Aug 28, 2:00 p.m. – 3:00 p.m.
Speakers: Seth Crosby & Kyle Ruddy
Seth and Kyle will help attendees get more comfortable with using automation tools like PowerShell and PowerCLI. This session will feature an introductory overview, followed by several examples which attendees can start using in their environments immediately!

Session: VIN1709BU – Mac and Linux Users, Don’t Despair: PowerCLI Is There!
Date: Tuesday, Aug 28, 3:30 p.m. – 4:30 p.m.
Speakers: Luc Dekens & Alan Renouf
Luc and Alan will discuss how PowerShell and PowerCLI have gone multi-platform, what impact that has on your environment and your existing code, plus some keys to success.

Session: HCI2522BU – Getting Started with vSAN Automation
Date: Tuesday, Aug 28, 5:00 p.m. – 6:00 p.m.
Speakers: Alan Renouf & William Lam
Alan and William show attendess how to get started automating all the aspects of vSAN with tools such as PowerCLI and the vSAN management SDKs.

Session: VIN1992BU – A Deep(er) Dive with PowerCLI 10
Date: Wednesday, Aug 29, 8:00 a.m. – 9:00 a.m.
Speakers: Luc Dekens & Kyle Ruddy
Luc and Kyle will take a look at the more advanced use-cases when using PowerCLI to automate actions in your environment. From proper object handling to diagnosing speed issues to debugging and more, this session is going to be a deep dive into the “what’s possible” with PowerCLI.

Session: NET1528BU – PowerNSX: Bringing the Power of PowerCLI to VMware NSX Data Center
Date: Wednesday, Aug 29, 8:30 a.m. – 9:30 a.m.
Speakers: Nicholas Bradford & Anthony Burke
Nick and Anthony will show attendees what PowerNSX is and how to use it to help automate anything from ad hoc queries to complete NSX data center logical topologies.

Session: HCI2061BU – Forget Click, Click, Click: Manage vSAN at Scale with PowerCLI
Date: Wednesday, Aug 29, 11:00 a.m. – 12:00 p.m.
Speakers: Jase McCarty & Kyle Ruddy
Jase and Kyle will take an in-depth look at the ways vSAN can be managed with PowerCLI to easily achieve consistency and repeatability at scale.

Session: DEV2828BU – Automating IT Ops with Dispatch Serverless Framework
Date: Wednesday, Aug 29, 11:30 a.m. – 12:30 p.m.
Speakers: Alan Renouf & Berndt Jung
Alan and Berndt show off the power of serverless with Dispatch. Attendees will see how to setup and configure Dispatch, plus how to control event triggers with familiar tools, like PowerCLI, and existing scripts.

Session: NET1642BU – NSX-PowerOps: Day2 Ops, NSX Health, Security, and Automated Documentation
Date: Wednesday, Aug 29, 11:30 a.m. – 12:30 p.m.
Speakers: Hammad Alam & Puneet Chawla
Hammad and Puneet will discuss a community-built tool, NSX-PowerOps, which uses tools like PowerCLI and PowerNSX to create documentation of your environment.

Session: VIN3327BU – Documenting Your Virtual Infrastructure with PowerShell and PowerCLI
Date: Wednesday, Aug 29, 2:00 p.m. – 3:00 p.m.
Speakers: Tim Carman & Matthew Allford
Tim and Matthew take the burden of documentation and applies it to an open-sourced project which helps to document environments using nothing but PowerCLI.

VMware {code} Power Sessions

Session: CODE5560U – Closer look at vSphere programming and CLI interfaces
Date: Tuesday, Aug 28, 12:30 p.m. – 1:00 p.m.
Speaker: Vikas Shitole
Vikas will show off the wide variety of APIs, CLIs, and SDKs available for use with vSphere and how to get started with each one.

Session: CODE5547U – Deep dive into the Horizon View APIs & PowerShell module
Date: Tuesday, Aug 28, 1:00 p.m. – 1:30 p.m.
Speaker: Wouter Kursten
Wouter shows off some of the fantastic new cmdlets that have been created and added to the Horizon View Helper module which can be used to enable PowerCLI based automation of Horizon View.

Session: CODE5549U – A better way to see PowerCLI data
Date: Tuesday, Aug 28, 1:30 p.m. – 2:00 p.m.
Speaker: Jake Blecha
Jake will show how to wrangle all the object data PowerCLI can return to get access to what you’re looking for in the format you want.

Session: CODE5540U – PowerCLI Lint
Date: Tuesday, Aug 28, 2:15 p.m. – 2:30 p.m.
Speaker: Justin Sider
Justin will apply the concept of Linting and unity testing to PowerCLI code and introduce some tools to help make the process easier so you can write better and re-usable code.

Session: CODE5622U – It’s Magic! Automating VMware Cloud on AWS
Date: TBD
Speaker: Ryan Kelly
Ryan discusses how to start interacting with the VMware Cloud on AWS APIs with PowerCLI to automate your scalable, highly resilient, infrastructure in the cloud.

vBrownBag Sessions

Session: VMTN5513U – vDeploy – PowerCLI only method to fully deploy a VM
Date: Monday, Aug 27, 1:00 p.m. – 1:15 p.m.
Speaker: Russell Hamker
Russell will walk you through vDeploy, covering what it is, how to use it, and what it supports so you can automate the deployment of a Windows VM to any environment.

Session: VMTN5522U – Automating Troubleshooting with vSphere Operations Manager
Date: Monday, Aug 27, 1:45 p.m. – 2:00 p.m.
Speaker: Thom Greene
Thom will show how to leverage the vRealize Operations PowerCLI module to automate your troubleshooting workflows.

Session: VMTN5535U – Strategies to starting with PowerCLI
Date: Monday, Aug 27, 5:00 p.m. – 5:15 p.m.
Speaker: Seth Crosby
Seth will take you through a handful of valuable strategies for helping you overcome what is holding you back from managing your VMware infrastructure like a pro, with PowerCLI.

Session: VMTN5605U – Getting Started with GitHub for PowerCLI Users
Date: Tuesday, Aug 28, 5:15 p.m. – 5:30 p.m.
Speaker: Justin Sider
Justin will walk through a few different typical scenarios that system administrator experience and how GitHub can solve those issues. From public to private to internal repositories, attendees will gain an understanding how what each are, how to use the, and even some tips on securing them.

Session: VMTN5597U – Powershell, it’s not just for Windows anymore
Date: Wednesday, Aug 29, 10:45 a.m. – 11:00 a.m.
Speaker: Chris Nakagaki
Chris will demonstrate how to easily get up and running with PowerShell Core and PowerCLI on a Mac or Linux system, and where it could possibly go from here.

Session: VMTN5614U – Gentle Shutdown of a 2-node Starwind HCI Cluster using PowerCLI
Date: Thursday, Aug 30, 1:30 p.m. – 1:45 p.m.
Speaker: Matt Langguth
Matt will walk you through an issue with StarWind HCI clusters and how PowerCLI can come to the rescue and overcome the issue.

Meet the Experts

Session: Automate Your VMware Cloud on AWS Environment with Paul Gifford
Date: MTE5097U – Sunday, Aug 26, 3:15 p.m. – 4:00 p.m.
Come meet with Paul to discuss the automation of VMware Cloud on AWS with tools like PowerCLI.

Session: vSphere Automation and VMware Cloud on AWS with William Lam
Date: MTE5013U – Tuesday, Aug 28, 1:15 p.m. – 2:00 p.m.
Come meet with William to discuss vSphere and VMware Cloud on AWS based automation.

Session: PowerCLI with Kyle Ruddy
Date 1: MTE5063U – Wednesday, Aug 29, 3:15 p.m. – 4:00 p.m.
Date 2: MTE5007U – Thursday, Aug 30, 10:45 a.m. – 11:30 a.m.
Come meet with Kyle to discuss any thoughts, ideas, issues, or anything that comes to mind regarding PowerCLI.

Hands on Labs

Lab: SPL-1911-05-SDC_U – VMware vSphere Automation – PowerCLI
Date: Anytime the HOL area is open and available
Get hands-on with VMware PowerCLI. Gain familiarity with the tool, and then dive deeper into the functionality available with real world examples. Both new and experienced users are sure to learn something new about automating their environments.

Session: ELW-1911-05-SDC_U – Expert-Led Workshop – VMware vSphere Automation – PowerCLI
Date 1: Monday, Aug 27, 2:30 p.m. – 4:00 p.m.
Date 2: Tuesday, Aug 28, 12:30 p.m. – 2:00 p.m.
Speaker: Howard Shoobe
Howard will show attendees how to get hands-on with VMware PowerCLI. You will gain familiarity with the tool, and then dive deeper into the functionality available with real world examples.

Hackathon

And last, but certainly not least, the VMware {code} Hackathon! If you’ve never been or haven’t heard of it, this is a fantastic event to get involved with other community members to do some coding! There’s no requirement to know how to code whatsoever. In fact, there are some trainings running before the Hackathon to help you get orientated.

Session: CODEHACK – VMware {code} Hackathon
Date: Monday, Aug 27, 6:30 p.m. – 11:30 p.m.
Join VMware {code} for the third annual hackathon!

Session: HACK6013U – PowerShell Primer: Prepping for Hackathon Success!
Date: Monday, Aug 27, 6:30 p.m. – 7:30 p.m.
Speaker: Kyle Ruddy
Kyle will cover a number of scenarios to help attendees get up to speed so they can use PowerShell to succeed in their Hackathon quest.

Summary

If you’re looking for PowerCLI content, VMworld is the place to be this year! With 10 sessions, over 10 community sessions, multiple meet the experts, and several hands-on activities, there’s something for everyone regardless of skill level. Make sure you’re registered for VMworld and get these sessions added to your schedule today!

Automating File-Based Backups of vCenter Server Appliance

Did you know the vCenter Server Appliance (VCSA) has file-based backup options?

This ability was actually released in vSphere 6.5. However, there was one feature in particular that was missing: a scheduler. I’m happy to say that as part of vSphere 6.7, the VCSA received a backup scheduler!

Recently, my teammate, Emad Younis released a couple cool walkthroughs to the vSphere Central site to manage file-based backup and restore actions. Under the covers, both of these actions are served up by vSphere’s RESTful APIs and therefore PowerCLI can also be used to automate these actions! One other benefit of using the API, you don’t have to hand out the root credentials. Users with the ‘SystemConfiguration.Administrators’ permission are able to perform all of the following tasks through the API and PowerCLI!

To perform a file-based backup with PowerCLI, we’ll need to make use of the CIS module. Since the CIS module is a low-level module, let’s see a couple examples of this in action.

Create a File-Based Backup

Let’s first start with the process to perform a backup.

First step, log in to the CIS Service for the VCSA:

Next, we need to find the appropriate service to perform a backup:

File-Based Backup Example: Listing CIS Services

Based on the output, we will want the ‘com.vmware.appliance.recovery.backup.job’ service. We will store that into a variable so we can easily interact with that specific service. To see the method we are going to use, take that variable and pipe it to ‘Get-Member’.

File-Based Backup Example - Working with the CIS Service

As part of the respose, we’ll see two important items. First, the ‘create’ method which we’ll use to actually create the backup job. Second, the ‘Help’ property. We can use ‘Help’ to help us form the input for the backup job with the following command:

We can now fill in each of the parameters with information for our environment. There are a couple caveats here. First, the ‘parts’ parameter is expecting an input of an array type. Second, each of the password parameters require a special type in order to be accepted.

Finally, having input all of our information, we can create the backup job!

File-Based Backup Example: Creating Backup Job

We can combine this into a nice script as follows:

Create a Scheduled File-Based Backup

Let’s now take a look at creating a scheduled backup job with PowerCLI.

Following a similar process to the last task, we will want to use one of the services we found previously called: com.vmware.appliance.recovery.backup.schedules

This time, we see two inputs are required. First, the schedule ID. Second, the specification which is similar to the prior example. The ‘Help’ property will be quite useful to create both specifications.

Much like the prior example, this one too has some caveats. The Schedule ID input can be a string of your choosing. For reference, performing this process in the UI creates a default ID of ‘default’. The scheduling recurrence configuration can be done in many ways through the ‘days’ property. If a daily backup is desired, there’s no need for any input and it can be left ‘unset’. If a specific day/s are desired, the input has to be of an array type.

Here’s a script which can be used to create a scheduled file-based backup:

Afterwards, if you log into the VCSA Appliance Management Interface (VAMI), your backup schedule should look much like the following:
File-Based Backup Example: Creating a Backup Schedule

Summary

The ability to create file-based backups of your vCenter Server is a function that is only available to the VCSA. This function is made possible by a set of RESTful APIs which PowerCLI can also consume, with the additional benefit of not being reliant on the root account! This blog post walked through examples of creating a file-based backup job and creating a scheduled file-based backup job.

More information about VCSA file-based backup can be found on the vSphere Central site: vCenter Server Appliance 6.7 File-Based Backup

Let us know in the comments how you’re automating your VCSA backups!

New Release: VMware PowerCLI 10.1.1

It’s release day and we have another terrific update ready for you. VMware PowerCLI 10.1.1 includes some very important updates specifically for the Horizon View folks!

PowerCLI 10.1.1 includes brand new support for Horizon View 7.5. This is quite significant because Horizon View was released just a few short weeks ago and had quite a few amazing updates as well. More information about the Horizon View 7.5 release is available: Horizon 7.5 View Release Notes

PowerCLI 10.1.1 Support for Horizon

There are two other notable improvements which came thanks to the community! The first is around an issue where users were receiving ‘insufficient privileges’ when attempting to connect to the Horizon View server. The second is around an issue where users would occasionally receive an error message of ‘the request channel timed out while waiting for a reply after 00:01:39.9969495’. Both of these have been updated and should now work as intended!

Summary

VMware PowerCLI 10.1.1 is continuing to show the evolution in our processes to be able to bring the latest and greatest features to you faster and faster. With this release, there are new APIs available from Horizon View 7.5 plus a couple improvements to the way PowerCLI interacts with the Horizon View server.

It’s as simple as ‘Update-Module -Name VMware.PowerCLI’ to update your PowerCLI version!

Sample: Update-Module -Name VMware.PowerCLI

For more information on changes made in VMware PowerCLI 10.1.1, including improvements, security enhancements, and deprecated features, see the VMware PowerCLI Change Log. For more information on specific product features, see the VMware PowerCLI 10.1.1 User’s Guide. For more information on specific cmdlets, see the VMware PowerCLI 10.1.1 Cmdlet Reference.

Configuring Per-VM EVC with PowerCLI

vSphere 6.7 was released a couple weeks ago and there were a ton of new features announced. However, there was one feature I was particularly interested in and that was Per-VM EVC (Enhanced vMotion Compatibility).

Giving a brief, high-level overview, EVC can be used to set a baseline of CPU features available to a VM or a set of VMs. In the past, this was a cluster-based setting. It was really nice because you could take hosts which didn’t have the same CPUs, use EVC to apply a common CPU baseline, and still put them in a cluster to take advantage of features like DRS and HA. The problem is that once a VM left that cluster, the EVC configuration would no longer be enforced. With vSphere 6.7 that changes, EVC can now be applied at the VM object level. This is awesome because now a VM can move across clusters, across datacenters, or even out to VMware Cloud on AWS and remain powered on and compatible! Be on the lookout for a much deeper dive on Per-VM EVC by my counterpart Emad Younis shortly.

Currently, configuring a VM’s EVC mode with PowerCLI is only available through a low-level command. That means, to configure this setting, we’re going to need to use methods that are exposed through either Get-View or a VM’s ExtensionData.

Let’s take a look at how we can automate this new setting using PowerCLI!

Introduction

First things first, we need to cover some requirements. To configure Per-VM EVC we need a couple things, including:

  • vSphere 6.7 (vCenter and ESXi host version)
  • A VM with hardware version 14
  • PowerCLI 10.1.0

Once we have those all inline, we need to figure out what EVC mode is appropriate for this particular VM.

Determining the Desired EVC Mode

PowerCLI makes it extremely easy to figure out what EVC modes are available. Each ESXi host object has a top-level property we can use to discover what their maximum EVC mode is. Once we obtain that information from all the potential hosts, we choose the lowest baseline and configure the VM with that.

Obtaining an ESXi host’s maximum EVC mode can done with the following command:

Example: Discovering VMHost MaxEVCMode

From the above example, we can see that the VM’s EVC mode should be no higher than ‘intel-sandybridge’ to work on these hosts. If we anticipate moving this VM between vCenters, we would want to run the same command against the ESXi hosts managed by that vCenter. If we anticipate moving this out to VMware Cloud on AWS, we already know those hosts are configured to be at an EVC mode of ‘intel-broadwell’. Broadwell is a higher, more advanced, mode than Sandy Bridge, so we’re still going to use the Sandy Bridge mode for our VM.

For more details about each EVC mode and how they rank, see the following KB article: 1003212 – Enhanced vMotion Compatibility (EVC) processor support

Assigning EVC Mode

We’re now ready to configure the per-VM EVC mode for this particular VM. The method we’ll be using is ‘ApplyEvcModeVM_Task’. More information about this can be found in the vSphere 6.7 Web Services API: ApplyEvCModeVM_Task

Based on the documentation, we have a couple parameters available to use:

Parameter Type
mask completeMask
HostFeatureMask object Boolean

The ‘mask’ parameter is looking for the CPU masking features we wish to configure. This is where the API gets a little more advanced than the UI. Where the UI only allows us to set the top level EVC mode, the API enables us to either specify all the feature masks which correlate to the EVC mode or be as granular as to only specify specific masks, the choice is ours. To be clear, this method does not accept the top-level EVC mode as input. Personally, I configure all the feature masks so that the VM’s level is aligned with the top level EVC mode.

The second parameter is ‘completeMasks’. This parameter is essentially asking if the masks presented are the complete list of masks to enable for this VM. This parameter accepts true or false as input and defaults to true. This is another reason I, personally, specify all the feature masks because then there is no confusion over what is or is not enabled for the virtual machine object.

Before we run the method, we need to obtain a list of feature masks. Starting from a high level, we can obtain the EVC Modes which are supported by our present vCenter with the following command:

To only retrieve information about the ‘intel-sandybridge’ mask, we can add a ‘where’ statement searching for that as the ‘key’ property:

Then, to isolate the masks we will be using as inputs for the ‘mask’ parameter, we can store the ‘FeatureMask’ output into a variable:

The above can also be wrapped up into a one-liner with the following command:

We’re now ready to run the command as follows:

Putting It All Together

If we combine all of the code above, it will look like the following:

Example: Putting everything together to set Per-VM EVC mode of a single VM

In 6 lines of code, we’ve gone from a VM with no EVC mode to a VM configured with an EVC mode of ‘intel-sandybridge’!

Community Module

If you found all the above to be a little too cumbersome, there’s a community module you can use to simplify this entire process. This module is available on the PowerCLI Community Repository: PerVMEVC

The PerVMEVC module provides the following three functions:

  • Get-VMEvcMode
  • Remove-VMEvcMode
  • Set-VMEvcMode

Here’s an example of them in action:
Example: Community Module Usage

Summary

vSphere 6.7 came packed with new features. One feature in particular really enables VMs the mobility to run anywhere. That feature is Per-VM EVC. This new feature takes the cluster based EVC functionality we’re already familiar with and now makes it available at the VM object level. PowerCLI gives us the ability to automate the entire process through the API using the ‘ApplyEvcModeVM_Task’ method as well as a new community module that can be used to simplify the process!

Let us know in the comments what you think of Per-VM EVC mode!

New Release: VMware PowerCLI 10.1.0

April has been a release heavy month for VMware. We have seen releases for vSphere 6.7, the entire vRealize suite, Site Recovery Manager 8.1, Horizon 7.4.1, and quite a few more. As of today, PowerCLI is being added to that list with the release of 10.1.0!

PowerCLI 10.1.0 offers the following updates:

  • Support for vSphere 6.7
  • Support for NSX-T 2.1
  • New VMware.Vim module
  • New cmdlets for managing Auto Deploy script bundles

Let’s take a look at those and some of the other updates.

Updated Support

Compatibility is something very important to PowerCLI. PowerCLI version 10.1.0 adds support for both vSphere 6.7 and NSX-T 2.1. This update gives you access to continue automating the latest and greatest VMware releases, plus have access to all those new APIs!

PowerCLI Compatability

New Module

This new version of PowerCLI brings our 20th module! This new module is named: VMware.Vim The goal of this module is to be able to allow you to have access to the latest vSphere APIs, including those available as part of VMware Cloud on AWS.

New Auto Deploy Cmdlets

Auto Deploy has two new cmdlets available to help with management of script bundles. These new cmdlets are:

  • Set-ScriptBundleAssociation
  • Remove-ScriptBundle

The Set-ScriptBundleAssociation cmdlet allows us to configure ESXi hosts to be associated with specific Auto Deploy script bundles.

The Remove-ScriptBundle cmdlet allows us to remove script bundles from Auto Deploy in an automated fashion. This functionality was actually requested by the community as PowerCLI Idea 114, so it’s really cool to see the direct impact the community can have.

General Updates

There’s a number of other improvements available in PowerCLI 10.1.0 as well. The first of which is to allow Import-VApp to support SHA-256 and SHA-512 hash algorithms. Next, we have deprecated the ‘Version’ parameter for the New-VM and Set-VM cmdlets. This parameter has been replaced by ‘HardwareVersion’. The same deprecation has been applied to the VirtualMachine object as a whole. Instead of referencing the ‘Version’ property, reference the ‘HardwareVersion’ property instead. Then, the Get-TagAssignment cmdlet has had the functionality corrected so we can query tags on datastore clusters. Another shout out to the community for this update, since that’s how this was brought to our attention! Also, we have made some updates to the process of migrating a VM to a VMware Cloud on AWS environment.

Lastly, PowerCLI 10.0.0 brought a bit of a change when it comes to handling vCenter and ESXi certificates. Instead of producing a warning when connecting to resources using invalid or self-signed certificates, PowerCLI now produces an error. We found some valid certificates were still producing an error and have corrected that process with PowerCLI 10.1.0.

If you do need to change PowerCLI’s configuration for handling certificate validation, the following code can be used to ignore those invalid or self-signed certificates:

Wrap-Up

PowerCLI 10.1.0 is the second release of the year and its only April! This release brought support for both vSphere 6.7 and NSX-T 2.1. A new module was introduced, VMware.Vim, making PowerCLI 20 modules strong. Two new cmdlets were added to help in the management of Auto Deploy script bundles! Plus, there were a number of other improvements added as well.

Remember, updating your PowerCLI modules is now as easy as ‘Update-Module VMware.PowerCLI’.

Example: Update-Module to PowerCLI 10.1.0

For more information on changes made in VMware PowerCLI 10.1.0, including improvements, security enhancements, and deprecated features, see the VMware PowerCLI Change Log. For more information on specific product features, see the VMware PowerCLI 10.1.0 User’s Guide. For more information on specific cmdlets, see the VMware PowerCLI 10.1.0 Cmdlet Reference.

New Release: PowerCLI 10 Poster!

The release of VMware PowerCLI 10.0.0 was another big one for us. As a result, PowerCLI is now available on Linux, MacOS, and Windows! As part of every major release, there’s a large number of asks for the PowerCLI poster and today we’re releasing it!

The poster features a bit of a layout refresh which conforms to a more standardized poster sizing guideline, but still features all of our cmdlets, some basic examples, and links to helpful resources.

PowerCLI Poster

New Release: PowerCLI Poster

If you’re looking to print one out, they are best at 36 inches wide by 24 inches tall.

Be on the lookout for these posters coming to a VMworld and/or VMUG near you!

Let us know where you’re putting your poster and how you’re using it either in the comments or on Twitter by mentioning the PowerCLI account!

New Release: PowerCLI Preview for VMware NSX-T Fling

A new Fling has been released for PowerCLI! The PowerCLI Preview for NSX-T Fling adds 280 high-level cmdlets which operate alongside the existing NSX-T PowerCLI module.

What do I mean by ‘high-level’ cmdlets? There are generally two forms of cmdlets available through PowerCLI, high-level and low-level. High-level cmdlets abstract the underlying API calls and provide an easy to use and understand cmdlet, like Get-LogicalSwitch. Based on that, you can assume the output will be logical switches. However, every API call does not have a corresponding high-level cmdlet and that’s where the low-level cmdlets come into play. Low-level cmdlets interact directly with the API and therefore have complete coverage of the available API calls. An example of a low-level cmdlet would be Get-View, or in the case of the NSX-T module it would be Get-NsxtService. More information about the low-level cmdlet usage of the NSX-T module is available in the following blog post: Getting Started with the PowerCLI Module for VMware NSX-T

Why is this being released as a fling? This module is still being developed and we need your feedback! What cmdlets are you using the most? What should the output look like? What cmdlets aren’t working the way you think they should? What cmdlets are missing? As well as any other feedback you can come up with! The preference is to leave the feedback on the fling’s comments section. However, if you post it as a comment here, I’ll make sure the right people receive it.

With that said, let’s get started using this new module!

Geting Started

First, we’ll need to head out to the VMware Flings site, browse for the fling and download the zip file. Direct link: PowerCLI Preview for NSX-T Fling

Next, extract the module and place it into one of your $PSModule directories. Better yet, do it with PowerShell:

We can then verify the module was placed in the proper location and is available for us to use:

Unzipping the Fling download

Note: If you don’t see the VMware.VimAutomation.Nsxt module, you probably need to install the latest version of PowerCLI. Walkthroughs on how to do that are available:

Now that we can see the module, I would suggest browsing through all of the 280 cmdlets available in the module. We can do that with the following command:

Browsing through all the available cmdlets in the Fling Module

One last step before starting to use the new cmdlets, we need to authenticate to the NSX-T server. This requires the VMware.VimAutomation.Nsxt module because it makes available the ‘Connect-NsxtServer’ cmdlet. We can authenticate to the NSX-T server with the following command:

Authenticating to the NSX-T Management Server

We are now authenticated and ready to start pulling information from the environment. Following along with the prior blog post, let’s start by pulling information about our cluster. We can do that with the ‘Get-ClusterNodeConfig’ cmdlet.

Example: Get-ClusterNodeConfig

We can clean up the output through the use of the ‘Select-Object’ cmdlet with the following command:

Example: Simplifying output for Get-ClusterNodeConfig

Another item we looked at in the last blog post, Transport Zones. The ‘Get-TransportZone’ cmdlet can be used, however if we want to clean it up a bit we can run the following command:

Example: simplified output for Get-TransportZone

One last example, we’ll get the status of the cluster. This can easily be done with the ‘Get-ClusterStatus’ cmdlet. However, the results are probably not what you expect. The ControlClusterStatus and MgmtClusterStatus each have an additional nested property of ‘Status’ which we’ll need to gain access to for this to really make sense. To do that, we’ll create a custom dynamic property with PowerShell! These custom properties will be made of hashtables used as part of the ‘Select-Object’ cmdlet. Each hashtable will need a ‘Name’ and an ‘Expression’. Here’s an example of this concept with the ‘Get-ClusterStatus’ cmdlet:

Example: Get-ClusterStatus and handling nested property values

Summary

There’s a great new fling available called the PowerCLI Preview for NSX-T Fling. This fling adds an additional 280 high-level cmdlets for VMware NSX-T, like Get-TransportZone, which means that automating NSX-T has never been easier!

As with all of our Flings, please leave feedback on the Comments section! We want to know what you think. What cmdlets are you using the most? What should the output look like? What cmdlets aren’t working the way you think they should? What cmdlets are missing? As well as any other feedback you can come up with!