Home > Blogs > VMware PowerCLI Blog > Tag Archives: PowerCLI

Tag Archives: PowerCLI

New Release: PowerCLI 11.4.0

August is always a great month when it comes to new releases, and this year is no different. Even before VMworld, there have already been announcements for vSphere 6.7 Update 3, NSX-T 2.4.2, and a new version of HCX. The PowerCLI team has one more exciting release for you in the form of PowerCLI 11.4.0!

PowerCLI 11.4.0 comes with a bunch of new improvements. The Horizon View module has been updated to support the newest release of Horizon View which is version 7.9. There are a handful of updates to the Storage module, including updates and three new cmdlets. Lastly, there are numerous updates to cmdlets in the HCX module.

PowerCLI 11.4.0 comes with the following updates:

  • Add support for Horizon View 7.9
  • Added new cmdlets to the Storage module
  • Updated Storage module cmdlets
  • Updated HCX module cmdlets

Let’s take a closer look at some of the updates.

Storage Module Updates

The Storage module received a number of new updates, many of which are there to support brand new features released with vSAN 6.7U3! The first improvement is to the Get/Set-VsanClusterConfiguration cmdlets. These two cmdlets can now access and make use of the newly added functionalities of Proactive Rebalance and vSphere Update Manager baseline preference.

Example of Get-VsanClusterConfiguration and Set-VsanClusterConfiguration in action:
PowerCLI 11.4.0 - Storage Module Updates

It’s worth noting that those new properties will return no information, nor can you change them, until your vSAN cluster has been updated to version 6.7 U3, as noted in the above error message.

The Storage module also has a couple new cmdlets. The first is the Add-VsanObjectToRepairQueue cmdlet. This cmdlet can repair vSAN objects that are referenced when using the command. This functionality was formerly available with the Repair-VsanObject cmdlet, however this particular cmdlet has been modified to be an alias for Add-VsanObjectToRepairQueue. The other two new cmdlets are Get-VsanResyncingOverview and Get-VsanEnterMaintenanceMode. Both of these cmdlets operate only against vSAN clusters of version 6.7U3 or newer.

HCX Module Updates

The HCX module has seen a flurry of activity since its initial release, and PowerCLI 11.4.0 continues that trend. There are six cmdlets which have been updated to add new capabilities. The Get-HCXAppliance cmdlet returns new information about the current version of an appliance as well as any available versions which exist. This can be combined with the New-HCXAppliance cmdlet that will allow us to upgrade an appliance to one of the available versions. The Get-HCXContainer cmdlet now adds the ability to list containers of a “OrgVdc” type. The Get-HCXNetwork cmdlet adds the ability to view two more types of networks, NsxtSegment and OrgVdcNetwork. Then, there is the New-HCXNetworkExtension cmdlet that can now work with networks of type NsxtSegment. Lastly, we have Get-HCXServiceMesh which has a new property available to view the status of several services.

Example of Get-HCXAppliance and Get-HCXServiceMesh, specifically viewing the new ServiceStatus property:
PowerCLI 11.4.0 - HCX Module Updates

A couple other issues were addressed with the HCX module as well. The Cmdlet Reference has been updated to reflect the .NET object type of an HCX Migration. Get-HCXServiceMesh and Get-HCXInterconnectStatus have both been updated to remedy issues. Lastly, the DestinationNetworkValue property now properly appears for replication objects.


This release of PowerCLI has some significant updates. PowerCLI 11.4.0 introduces new support for Horizon View 7.9, new functionality for vSAN 6.7 Update 3 objects, and numerous updates to the HCX module!

For more information on changes made in VMware PowerCLI 11.4.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 11.4.0 User’s Guide. For more information on specific cmdlets, see the VMware PowerCLI 11.4.0 Cmdlet Reference.

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

Let us know in the comments what you’re looking forward to most!

PowerCLI at VMworld US 2019

VMworld US Banner

Would you believe it, VMworld is already right around the corner! This year, VMworld has all kinds of sessions related to PowerCLI. From the introduction and deep dive sessions to more specifically focused sessions on VMware Cloud on AWS, vSphere update lifecycle, vSAN, and even Horizon View. There’s also a very special session given by a member of the PowerCLI engineering team which gives a special look at how new features are added automatically! Plus, a bunch of community sourced sessions and the always fantastic Hands-on-Lab! If you haven’t already registered, the time is quickly ticking away!

Schedule builder is already live, so make sure to add the following sessions to your schedule and catch up with the PowerCLI team and all of the amazing PowerCLI community members! And if the session is already full, don’t worry. Join the waitlist and help us move these sessions to larger rooms!

Breakout Sessions

Session: HBI1743BU – Introduction to PowerCLI
Date: Monday, August 26, 02:30 PM – 03:30 PM
Speakers: Brian Bunke & Kyle Ruddy
Brian and Kyle will show how PowerCLI is one of the easiest ways to manage your environment and how you can easily get started in your own environments.

Session: HBI1729BU – PowerCLI Deep Dive
Date: Thursday, August 29, 12:00 PM – 01:00 PM
Speakers: Luc Dekens & Kyle Ruddy
Luc and Kyle are back with another edition of the PowerCLI Deep Dive, where they’ll show you some of the advanced methods they use to make even the hardest of tasks look easy.

Session: HBI1463BU – VMware Cloud on AWS: Advanced Automation Techniques
Date: Wednesday, August 28, 01:00 PM – 02:00 PM
Speakers: William Lam & Kyle Ruddy
William and Kyle will walk you through the available APIs and tooling for VMware Cloud on AWS, then demonstrate they can be used to automate all aspects of the SDDC lifecycle and workload consumption.

Session: HCI1864BU – Automating vSAN from CLI to API: PowerCLI, Govc, and Beyond
Date: Wednesday, August 28, 09:30 AM – 10:30 AM
Speakers: Cedric Rajendran & Dharmesh Bhatt
Cedric and Dharmesh will show how to automate some of the routine vSAN tasks using the wide variety of APIs and CLIs available and at your disposal.

Session: HCI1825BU – Automate VMware HCI Deployments at Any Scale with PowerCLI
Date: Wednesday, August 28, 02:00 PM – 03:00 PM
Speakers: Shane Limbach & Jase McCarty
Shane and Jase will show you how to harness the power of PowerCLI to build, manage, and report on your vSAN environment regardless of scale.

VMware {code} Sessions

Session: CODE2214U – How PowerCLI Makes Configuration Management Easy
Date: Tuesday, August 27, 01:00 PM – 02:00 PM
Speaker: Kyle Ruddy
Kyle will cover some configuration management principles and then dive in to show the latest ways PowerCLI is using PowerShell DSC to make vSphere configuration management easy.

Session: CODE1817UR – Automating vCenter Server Appliance Update Lifecycle
Date: Wednesday, August 28, 09:00 AM – 09:30 AM
Speaker: David Stamen
David will show off his new community module for PowerCLI which can be used to ease the lifecycle management of the vCenter Server Appliance.

Session: CODE2649U – How PowerCLI Gives Day 1 Access to the Latest VMware APIs
Date: Wednesday, August 28, 04:00 PM – 04:30 PM
Speaker: Nikola Klinkachev
Nikola, an engineer on the PowerCLI team, will provide a “look behind the curtain” when it comes to how PowerCLI can automatically interact with the latest and greatest APIs.

Session: CODE1316UR – Horizon 7 Automation 101: How to Get Started with the Horizon API
Date: Wednesday, August 28, 09:30 AM – 10:00 AM
Date: Thursday, August 29, 09:00 AM – 09:30 AM
Speaker: Jack McMichael
Jack will provide an overview of the Horizon 7 API and how PowerCLI can be leveraged to simplify the automation process for those Horizon environments.

VMTN TechTalk Sessions

Session: VMTN5040U – Beginning PowerShell from Cmdlet to Function
Date: Tuesday, August 27, 05:30 PM – 05:45 PM
Speaker: Mike Nelson
Mike will cover a quick introduction to PowerShell, as well as PowerCLI, to help you down the path of getting started with PowerShell.

Session: VMTN5004U – ReportCardPS – Create Pretty Reports Using PowerCLI and Clarity
Date: Wednesday, August 28, 01:00 PM – 01:15 PM
Speaker: Justin Sider
Justin will show you how to easily combine the reporting power of PowerCLI with the UI stylings of clarity to create amazing reports.

Session: VMTN5026U – Automating VDI Tasks, the story of the life of a VDI admin
Date: Thursday, August 29, 01:00 PM – 01:30 PM
Speaker: Chris Hildebrandt
Chris will tell you his personal story of how he learned to automate his daily tasks with, amongst other things, PowerCLI to make him more productive as a VDI administrator.

Hands on Labs

Lab: SPL-2012-01-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-2012-01-SDC_U – Expert-Led Workshop – VMware vSphere Automation – PowerCLI
Date: Tuesday, August 27, 02:15 PM – 03:45 PM
Date: Thursday, August 29, 08:30 AM – 10:00 AM
Speaker: Peter Kieren
Peter 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.


VMworld US 2019 continues to be the premier event to learn about PowerCLI. Come hear directly from the PowerCLI team, as well as numerous community members, how you can harness PowerCLI to automate even the most difficult of tasks.

Make sure you’re registered for VMworld today!

Check Out VMware Code’s Talking Code

Talking Code
There’s a new(-ish) series going on through VMware Code, it’s called Talking Code. This series has been taking a look at new features, such as Code Capture, as well as how to accomplish certain tasks in short, demo-based videos. PowerCLI has been featured in several of these videos already posted to the VMware Code blog and will continue to be included going forward.

Here’s a sampling of some of the PowerCLI based videos already available:

For a complete list of the videos in the Talking Code series, see the: Talking Code Archive

If there’s anything you would like to see covered in the future, let us know in the comments!

New Release: VMware PowerCLI 11.3.0

Today marks the release of VMware PowerCLI 11.3.0 and this one brings the count up to 732 different cmdlets. The combination of all these cmdlets allow us to manage and automate a majority of the VMware ecosystem! The HCX module receives the bulk of the new cmdlets, however there is also a new cmdlet to interact with the vSphere Storage Policy Based Management (SPBM) APIs. There is a new way to view opaque network types and a high-level method of promoting instant clones to full clones. Last, but certainly not least, this release also includes a handful of updates for reported issues and two deprecations.

PowerCLI 11.3.0 comes with the following updates:

  • Added 22 new cmdlets for HCX and SPBM management
  • Added support for vSphere 6.7 Update 2 to the VMware.VIM module
  • Added support for opaque networks to the Get-VirtualNetwork cmdlet
  • Added support for the creation of additional network adapter types
  • Added support for the high-level promotion of instant clones
  • Updated the handling of a Cluster’s ‘SpbmEnabled’ status
  • Updated the handling of bulk tagging assignments

Let’s take a more in-depth look at some of the updates.

Tag Improvements

vSphere tags are always a popular discussion. Normally, the conversation ends up being about performance. This update, with PowerCLI 11.3, allows us to make use of the backend API where we can perform bulk assignment of tags. This means that the New-TagAssignment cmdlet has been updated to allow for arrays to be passed for either the Entity or Tag properties. In my test environments, I am able to report anywhere from a 12x to 18x improvement in performance. Of course, the performance will vary by environment. The following is an example of running the same set of 100 vSphere tags to a single VM. In PowerCLI 11.3, the task took 1.771 seconds whereas in PowerCLI 11.2, it took 32.495 seconds. That’s a pretty impressive improvement.

Example: Bulk Tag Assignment Operations

For more information about general vSphere tag performance with PowerCLI, check out a recently released blog from the Performance team: Writing Performant Tagging Code

New Cmdlets for HCX

VMware HCX is best thought of as a swiss army knife – a single tool with multiple options to move your workloads in and out of the cloud. The HCX module was introduced just earlier this year, in PowerCLI 11.2.0, as the 21st module for PowerCLI. New in PowerCLI version 11.3.0, the module receives an additional 21 cmdlets to interact with your HCX deployment. A majority of the new cmdlets deal with profiles, which are used as a site’s deployment configurations for items like storage, compute, and networking. There are also new cmdlets to manage the HCX Service Mesh, which is composed of the source and destination sites.

A complete list of the newly added cmdlets:

  • Get/New/Remove/Set-HCXComputeProfile
  • Get-HCXInventoryCompute
  • Get-HCXInventoryDatastore
  • Get-HCXInventoryDVS
  • Get-HCXInventoryNetwork
  • Get-HCXNetworkBacking
  • Get/New/Remove/Set-HCXNetworkProfile
  • Get/New/Remove/Set-HCXServiceMesh
  • Get-HCXStorageProfile
  • New-HCXComputeProfileDVS
  • New-HCXComputeProfileNetwork
  • New-HCXServiceMeshDVS

More information on using the HCX module can be found in the following blog post: Getting Started with the HCX Module

Opaque Network Support

Another improvement to the PowerCLI 11.2 release was the addition of a new object type for opaque networks. These network types are the result of logical switches that have been created in NSX-T. That update allowed us to retrieve these objects through only low-level, direct API access, commands. With PowerCLI 11.3, the Get-VirtualNetwork cmdlet has been updated so we can now view opaque networks with a high-level cmdlet!

An example of using Get-VirtualNetwork to display distributed, opaque, and standard networks:
Example: Showing all types of virtual networks

For some additional information about working with opaque networks in vCenter, see the following blog: Configuring VMs with Opaque Networks

Instant Clone Promotion

Instant Clone is a functionality which has been around VMware in one form or another for quite a while. First discussed as “VMFork”, going back as early as 2014, this allows us to immediately create a child VM based off of a presently powered on VM, which we can then viewe as a cloned VM in vCenter. vSphere 6.7 was the first release to have this available as a public feature, though it was only available through the API. This is where PowerCLI, and specifically version 11.3, comes into play because we can now make use of the Set-VM cmdlet combined with the PromoteDisks parameter against one of the available child VMs to create a fully cloned VM object. The selling point is that afterwards, there is no longer a dependency on that parent VM!

Look for more information about this great new functionality in a future blog post.

SPBM Updates

The last big update we’re going to cover is for those looking to automate the management of vSphere Storage Policy Based Management (SPBM) policies. The first update comes in the form of a new cmdlet named Get-SpbmView. This cmdlet gives us direct access to the available APIs for SPBM. In the example below, we can see the usage of this cmdlet to list out the available services and start to interact with the Replication Manager service to see the available methods.

Example: Get-SpbmView Usage

The other update is to how the Get/Set-SpbmEntityConfiguration cmdlet operates. Both of these cmdlets can now display or modify policies for datastores. However, there is also a deprecation for cluster objects and whether they display an “SpbmEnabled” status. This is due to a change, which happened as of vSphere 6.0, where clusters always have a status of “Enabled.” Here is an example of using the Get-SpbmEntityConfiguration to display information about the specified datastore.

Example: Viewing SPBM Policies for datastores


The second release of the year is here in the form of PowerCLI 11.3.0. This release adds 22 new cmdlets to help automate workload migrations and granular management of SPBM policies. There are new ways to manage network-based objects, whether those are networks themselves or network adapter types. We can also now upgrade an instant clone to a full clone with an easy to use, high-level cmdlet. Lastly, bulk tag assignment is now a supported mechanism of the New-TagAssignment cmdlet.

For more information on changes made in VMware PowerCLI 11.3.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 11.3.0 User’s Guide. For more information on specific cmdlets, see the VMware PowerCLI 11.3.0 Cmdlet Reference.

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

Let us know in the comments what you’re most excited about!

New Release – DSC Resources for VMware 2.0

The Desired State Configuration (DSC) Resources for VMware was released late last year. This initial release was able to leverage the PowerShell DSC engine in order to declare configurations for a handful of ESXi host settings and a couple vCenter server settings. The response to these resources has been amazing! So amazing that over the last 7 months, there have been 64 issues and 74 pull requests. A result of all of that feedback, input, and code contributions brings us to the next release, version 2.0 of the DSC Resources for VMware!

The DSC Resources for VMware version 2.0 contains a number of new resources, lots of improvements, and a new way to access them. First and foremost, as requested, these resources are now available on the PowerShell Gallery! There are also a number of examples which have been added to the repository since the first release. In the root of the repo, there’s an ‘Examples’ folder which contains some examples of combining multiple resources into a single configuration. Then, within the resource itself, there’s a folder by the name of ‘Configurations’. This folder has example configurations of using these resources with configuration management utilities like Ansible, Chef, and Puppet. Lastly, there are 14 new resources for us to use!

Let’s walk through some of the new resources.

New Resources

These newly added resources can be easily categorized into the following buckets: Inventory, vSphere Standard Switch (vSS), and VMHost.

The new Inventory resources, which allow us to manage the existence of these object types, are:

  • Cluster
  • HACluster
  • DRSCluster
  • DatacenterFolder
  • Datacenter
  • Folder

The following is an example of using the Folder resource to manage a VM based folder, named Management, along with a folder nested in the first folder:

The new vSS resources, which allow us to manage a VMHost’s vSS configuration, are:

  • VMHostVss
  • VMHostVssBridge
  • VMHostVssSecurity
  • VMHostVssShaping
  • VMHostVssTeaming

The following is an example of using the VMHostVss resource to manage a vSS on a particular VMHost:

The new VMHost resources, which have been added to the already existing set of resources that manage VMHosts, are:

  • VMHostService
  • VMHostSettings
  • VMHostSyslog
  • VMHostAccount

The following is an example of using the VMHostService resource to manage an ESXi host’s SSH service to ensure it is running and the policy is set to automatic:

Here’s a demo which combines a number of the new resources for the following configuration:
Datacenter: DemoLab
Folder Structures:
- Linux
- Windows
- Linux
- Windows
- VMware
- Linux
- Windows

PowerCLI DSC v2 Resources Demo


The DSC Resources for VMware have only been available for a short period of time, however they have made a tremendous impact! Over the last 7 months, there have been 64 issues and 74 pull requests to the GitHub repository. Today, we’re taking the culmination of that input and releasing the 2.0 version of these resources. This adds an additional 14 resources, a number of functionality improvements, and they have been added to the PowerShell Gallery!

I also want to say a special thank you to some of our community contributors: Luc Dekens, for his immense contributions to this release including having a hand in at least 8 of the new resources as well as Brett Johnson and Markus Fischbacher for their contributions as well!

To get started, it is now as simple to install as:

Demo: DSC Resource Installation

For more information on this release, see the latest release page on the DSC Resources for VMware GitHub page.

Let us know in the comments how you’re using these in your environment and what resources you’re looking for next!

Automating VMware Cloud on AWS SDDC Cluster Lifecycle

VMware Cloud on AWS has the ability to add new clusters to an existing SDDC. This is most useful for workload separation. A cluster could be specified as the failover resource, a development environment, and so forth. However, as of Version 1.6, there’s a new reason to add new clusters to an SDDC: custom core counts! The ability to control the CPU count for hosts in a cluster is extremely important when it comes to running mission-critical applications that happen to be licensed per-core. Even better, it is extremely easy to automate the lifecycle of a cluster with PowerCLI.

Let’s check out some examples of how we can manage clusters within the VMware Cloud on AWS service.

Environment Setup

As part of this blog, I will be using a previously deployed SDDC and will begin by working with the low-level VMC module to perform these tasks. We will start by opening a PowerShell session and authenticating to the VMware Cloud on AWS service with our API Token. Then, we need to identify a couple services to use. These services will be the following:

  • com.vmware.vmc.orgs
  • com.vmware.vmc.orgs.sddcs
  • com.vmware.vmc.orgs.sddcs.clusters
  • com.vmware.vmc.orgs.tasks

One last setup requirement, we will need to grab IDs for the Organization and SDDC which we’ll be working with.

We can summarize the above criteria with the following code:

If any of these commands seem foreign, please check out the following blog post for more information: Getting Started with the VMware Cloud on AWS Module

SDDC Cluster Service Overview

We will be using the SDDC Clusters service, and therefore the sddcClusterSvc variable. In order to discover the actions we can perform with the Clusters service, we will take the output from the sddcClusterSvc variable and pipeline that into the Get-Member cmdlet:

Sample: Getting additional information from the SDDC Cluster Service

Here we can see that there are two methods available, create and delete. As part of this blog post, we will walk through the usage of these two methods in the following sections. However, there’s a method or two that are missing, get and list. We can pull that information directly from the get method on the SDDC itself. The cluster information is available by referencing the resource_config property, then the clusters property.

To pull out some basic cluster information, we can use the following command:

Example: Pulling output from the SDDC response about only the clusters

Cluster Creation

For the first example, we have been tasked with creating a new cluster within our SDDC.

In order to populate the parameters for the create method, we will make use of the Help property for the SDDC Cluster service stored in the sddcClusterSvc variable. We can identify all of the parameters required for the create method, including an Org ID, SDDC ID, and the cluster configuration specification, with the following command:

Example: Output from Help for the Create method

We already have our Org ID and SDDC ID stored in a variable. Next, we need to create a cluster config spec for the new cluster. If we take the prior command and append the ‘cluster_config’ property, we can view all of the properties available to populate the spec. Then, by again using ‘Get-Member’, we can see that the cluster_config has a method of create which we can use to create the object for that particular specification.

Example: Establishing the contents for the Cluster Config spec

We’ll then store the spec in a variable named sddcClusterCreateSpec. Based on the prior screenshot, there’s only one required property. This property is for the desired number of hosts for the new cluster. We’ll populate that property with a value of ‘1’, then run our create method to start the creation of the new cluster.

Example: Creating a new cluster with 1 host

Putting the above together, we can create a new cluster with a single host using the following code:

If we login to the VMware Cloud on AWS Cloud Console, we should see the following in our SDDC’s Summary tab:

Example: SDDC Cluster Deployment

Cluster Creation – Custom Core Count

For the second example, we have been tasked with creating another new cluster within our SDDC. However, this time, we only want a specific core count to be available. We will use our prior example and add-on to the specification by setting the host_cpu_cores_count to be a value of 8, 16, 36, or 48, depending on the host type. We can do this by adding the following command to the existing workflow:

Putting the prior example together with the above command, we can create a new cluster with a single host that’s been configured with a CPU core count of 8 using the following code:

Example: Creating a new cluster with 1 host and only 8 CPU cores per host

Cluster Removal

For the third example, we have been tasked with deleting the first cluster we created, Cluster-2. Making use of the Help property from the SDDC Cluster service, we can run the following command to find out what parameters the delete method requires:

Example: Output from Help for the Delete method

We can see that we have three parameters to enter: Org ID, SDDC ID, and Cluster ID. We still have the first two stored in variables, so we need to obtain the Cluster ID. If we remember back to the SDDC Cluster Service Overview section, there’s no list or get methods for the SDDC Cluster service. Therefore, we need to refresh our sddc variable and return back the updated list of clusters to obtain the ID. We can do that with the following commands:

We will then store the cluster information for only Cluster-2, by filtering the cluster_name property with a where statement and storing it in a variable by the name of cluster. Then, we’re ready to run the delete method. We can do that with the following commands:

Example: Deleting a cluster from an SDDC

Putting the above together, we can delete the newly created Cluster-2 with the following code:

VMC Community Module Update

Another option to perform the above tasks is with the VMware.VMC community module, which is available on the PowerCLI Community Repository as well as the PowerShell Gallery. I have updated the module to include the following advanced functions:

  • Get-VMCSDDCCluster
  • New-VMCSDDCCluster
  • Remove-VMCSDDCCluster

The only difference between the above sections and these functions, these functions expect names instead of IDs as input. Otherwise, they work exactly as you would expect. An example of them in use:

Example: Using the SDDC Cluster functions from the VMware.VMC module


VMware Cloud on AWS based SDDCs can contain multiple clusters, which is beneficial for a couple reasons. First, workload separation. A cluster could be specified as the failover resource, a development environment, and more. Second, and new as of Version 1.6, these clusters can be deployed with a specific amount of CPU cores. This control is certainly important when it comes to running mission-critical applications that happen to be licensed per-core. All of the cluster actions are available via the VMware Cloud on AWS APIs, and therefore PowerCLI as well! This blog post walked us through how to identify the deployed clusters, deploy new clusters, and remove clusters which are no longer needed.

Let us know in the comments how you’re making use of additional clusters in your automation workflows!

New Release: PowerCLI 11.2.0

The first release of 2019 is here! Today marks the release of PowerCLI 11.2.0 and it is an exciting one. PowerCLI now has 21 modules, to ensure you can automate roughly any VMware product. We’re adding new, and more secure, methods to authenticate. There are also improvements to existing cmdlets so you can use the latest and greatest technologies alongside the newest APIs available.

PowerCLI 11.2.0 comes with the following updates:

  • New module available for VMware HCX
  • Added support for NSX-T Policy services
  • Added support for OAuth based connectivity to vCenter
  • Added support for Opaque Networks
  • Updated Storage module cmdlets

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

New Module for VMware HCX

VMware HCX is an amazing option that breathes new life into the term Hybrid Cloud. To give a quick overview, think of VMware HCX as a swiss army knife – a single tool with multiple options to move your workloads in and out of the cloud. Schedule migrations with HCX vMotion, take advantage of replication assisted vMotion for bulk migrations and even VMs with larger footprints, or protect your data with the available disaster recovery options. HCX is a powerful tool to easily manage the location of your workloads, and PowerCLI now offers 20 cmdlets to help automate its management.

More information on this exciting, new module can be found on the following blog post: Getting Started with the HCX Module

Added Support for NSX-T Services

NSX-T gives administrators the ability to abstract the management of the applied networking, security, and even availability into what’s known as policies. These policies greatly simplify the management experience. Making it even simpler, with the new Get-NsxtPolicyService cmdlet, we can now use PowerCLI to automate these policies with direct connectivity to the API. This cmdlet is also compatible with the newly announced NSX-T 2.4!

PowerCLI Compatibility Matrix with NSX-T

The new policy service cmdlet is great, but that isn’t the only update for NSX-T PowerCLI 11.2.0 comes with. There’s also new support for opaque networks in some of the cmdlets we already know and love. The cmdlets updated to support opaque networks are: Set-NetworkAdapter and Import-VApp.

For more information about how to use these cmdlets with opaque networks, see the following blog: Configuring VMs For Opaque Networks

Updated Authentication Support

Security is always an important topic, especially when it comes to automation. As part of VMware Cloud on AWS, there has been an update to expand into GovCloud. In order to participate in GovCloud, the service has to adhere to a more stringent set of security and privacy controls. The control that will be the most noticeable for PowerCLI users will be around authentication. Therefore, we have added two new cmdlets and updated an existing cmdlet to support OAuth2. For the VMC module, we have a new cmdlet, named New-VcsOAuthSecurityContext, which will produce an OAuth security context based off our VMware Cloud on AWS refresh token. For the Core module, there’s a new cmdlet, named New-VISamlSecurityContext, which will take the OAuth security context and translate it to a SAML2 security context. That SAML2 security context can then be used with the updated cmdlet, Connect-VIServer, to authenticate to the vCenter.

This exchange should look like the following:

It’s worth noting, at this point in time, this functionality is reserved only for GovCloud instances of VMware Cloud on AWS deployed SDDCs.

Storage Module Updates

Last, but certainly not least, the Storage module has a number of updates. The Get-VsanSpaceUsage cmdlet has a new parameter which allows us to return results for a specific storage policy. There has been quite a few new parameters added to the Set-VsanClusterConfiguration cmdlet, which includes: CustomizedSwapObjectEnabled, GuestTrimUnmap, LargeClusterSupported, ObjectRepairTimerMinutes and SiteReadLocalityEnabled. Another updated cmdlet is Test-VsanNetworkPerformance, which now has a DurationInSecond parameter so we can control how long the performance test actually lasts.

For more information about the updates to the Storage module, see the following post by my colleague Jase McCarty: PowerCLI 11.2 Released, with more goodness for vSAN!


The first PowerCLI release of 2019 has some significant improvements. PowerCLI 11.2.0 introduces OAuth2 support and the ability to access the new NSX-T Policy APIs, plus an entirely new module containing 40 cmdlets to manage HCX!

For more information on changes made in VMware PowerCLI 11.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 11.2.0 User’s Guide. For more information on specific cmdlets, see the VMware PowerCLI 11.2.0 Cmdlet Reference.

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

Example: Update-Module

Let us know in the comments what you’re most excited about!

Getting Started with the HCX Module

PowerCLI 11.2.0 introduced a brand-new module that allows us to easily automate VMware HCX! The VMware.VimAutomation.HCX module adds 20 new cmdlets to already existing count of well over 600 cmdlets contained in the entire set of PowerCLI modules. This is important because HCX is one of the newest technologies VMware has released and it has some impressive power.

To give a quick overview, think of VMware HCX as a swiss army knife – a single tool with multiple options to move your workloads in and out of the cloud. Schedule migrations with HCX vMotion, take advantage of replication assisted vMotion for bulk migrations and even VMs with larger footprints, or simply protect your data with the available disaster recovery options. HCX is a powerful tool to easily manage the location of your workloads.

For more information on HCX itself, see the following blog article from my colleague Emad Younis: Learning Hybrid Cloud Extension (HCX)

My lab environment is shared between a couple of my peers and I didn’t happen to deploy HCX to this environment. So, let’s walk through a couple examples of using the HCX module to perform some environment discovery and follow that up with performing an HCX vMotion.

Getting Started

The first time I use a module, I examine the cmdlets that are available. We can do that with the following code:

We can see in the response that each of the cmdlets have a prefix, for the noun portion, of HCX. There’s the standard Connect-HCXServer and Disconnect-HCXServer cmdlets for authentication, along with the low-level Get-HCXService cmdlet so we can access the API directly. The other cmdlets are high-level, which have abstracted the available API calls and provided us with easy to understand names and parameters.

First, we need to authenticate to our HCX environment. We will connect directly to the on-premises HCX Manager using the Connect-HCXServer cmdlet.

Example: Connect-HCXServer Output

Now that we’re connected, we can take a look at some of the appliances which have been deployed. We can use the Get-HCXAppliance cmdlet to do that.

Example: Get-HCXAppliance Output

We can see that we have 3 appliances deployed and the type for each of them. This falls in line with what you would see under the “HCX Components” tab of the Infrastructure Interconnect page in the HCX Management UI.

Another piece of information on that particular page is the status of the Interconnect. We can receive that with the Get-HCXInterconnectStatus cmdlet.

Example: Get-HCXInterconnectStatus

We also want to know some site-based information. We can make use of the Get-HCXSite cmdlet to do this. However, we will be making use of two parameters to get the full picture. These two parameters are Source and Destination. If no parameter is used, we’ll receive the source site information by default.

Example: Get-HCXSite Output

There are also a handful of cmdlets to help us discover the what vSphere objects are available to the HCX environment. These include Get-HCXVM, Get-HCXDatastore, Get-HCXNetwork, and Get-HCXContainer. The first three should be fairly obvious, but the fourth cmdlet is a little more ambiguous. Get-HCXContainer returns back a list of multiple object types including clusters, datastores, folders, hosts, and resource pools.

Example: Get-HCXContainer Output

One item to take note of, by default each of these cmdlets only return objects for the source site. If you want to receive objects from some other site, you will need to specify that with the Site parameter.

At this point, I think we’re fairly familiar with our environment so let’s take a look at performing an HCX migration!

HCX Migration

The HCX Migration service offers numerous ways to migrate our VMs between the available sites. There are five cmdlets to help us automate migrations.

We can start off by using Get-HCXMigration to see a status on any existing migrations. In this case, there has been one previous migration and we can use the “Format-List” parameter to see the all the properties for the HCXMigration object.

Example: Get-HCXMigration Output

Next, let’s perform an HCX Migration. We’ll need to populate a handful of parameters to create the migration with New-HCXMigration. This is quite similar to performing a standard vMotion between vCenters with Move-VM. One big caveat though, the New-HCXMigration cmdlet is looking for HCX objects and not the standard objects we receive from vCenter. Therefore, we’ll be using the HCX associated cmdlets to create variables for each of those parameters.

Here’s some example code based on my environment:

Then, we can run our New-HCXMigration cmdlet. In my environment, I stored the output from the cmdlet into a variable since we will need to reference it later.

Example code:

Our migration is created, but it hasn’t actually started yet. There’s one more step to perform before we start the migration, and that’s testing the migration!

Example code:

Assuming a successful validation, we can now move onward to performing the migration with the Start-HCXMigration cmdlet.

Putting the above altogether, it should look similar to the following:

Example: New Migration Workflow


A new module has been made available as part of PowerCLI 11.2.0 to automate VMware HCX. This module includes 20 cmdlets which can be used to discover HCX environments and automate the lifecycle of network extensions, migrations, and disaster recovery replication. PowerCLI makes it easier than ever to migrate and protect your workloads!

Let us know in the comments what HCX actions you’re using PowerCLI for!

Configuring VMs For Opaque Networks

PowerCLI has a new object to interact with, thanks to NSX-T! The Opaque Network managed object gives us the ability to interact with NSX-T provisioned logical switches as though they are port groups. Technically, it has been available for a couple releases of vSphere but the functionality was really improved here recently.

Last year we released KB 65149 that included code to create a new function, named Set-NetworkAdapterOpaqueNetwork. This function could be used to assign an opaque network to a VM’s network adapter. I’m happy to relay that, as of PowerCLI 11.2.0, we no longer have to rely on that function. We can now use the Set-NetworkAdapater to assign an opaque network just as we would any other normal port group with the NetworkName parameter. We also have the ability to deploy OVAs and/or OVFs with an opaque network configured in the OVFConfiguration parameter.

Before we dive into some coding examples, we should begin by showing how to list out the available opaque networks. This is because opaque networks aren’t included as part of the response for either Get-VirtualPortGroup or Get-VDPortGroup. Each of those cmdlets return their own object types. Therefore, we need to rely on the Get-View cmdlet to interact directly with the vSphere Web Services API.

Retrieving Opaque Networks

We can list all of our vCenter’s opaque networks with the following command:

Since we’re interacting directly with the API, we’re going to receive back all of the top-level information about each opaque network. We can condense the output and make it a little easier to read with the following code:

Sample: Condensed output from listing opaque networks

Configuring Opaque Networks

We now have a list of opaque networks which are available for us to use. The next step is to start configuring our VMs to use them. As of PowerCLI 11.2.0, we can use the already existing Set-NetworkAdapter cmdlet combined with the NetworkName parameter to make the change.

We can update a VM’s port group association to be an opaque network with the following code:

Example: Set-NetworkAdapter Usage


NSX-T adds a new object for PowerCLI to interact with in the form of an opaque network. These are a representation, at the vSphere level, of a logical switch which has been provisioned from NSX-T. PowerCLI 11.2.0 includes updates to existing cmdlets that allow us to assign opaque networks to our VMs as port groups. The first, which was demonstrated in this post, is to modify a VM’s network adapter with the Set-NetworkAdapter cmdlet paired with the NetworkName parameter. The second, while deploying OVAs and/or OVFs through Import-VApp when using the OvfConfiguration parameter.

Update today to the latest version of PowerCLI to ensure you have access to the latest features and functionalities.

Moving a Datastore Cluster to a New Folder

We often get lots of interesting requests about figuring out how to automate something. The latest request was about how to move a datastore cluster between folders. This is the type of automation action which probably doesn’t need to be used all that often and is more aesthetic in nature than anything else. However, the interesting part is that, this request came from someone that found out they couldn’t perform the action in the UI. So, PowerCLI to the rescue!


PowerCLI doesn’t have a high-level cmdlet for this action, so we’ll be creating our own. To perform this action, we’ll be using a method that’s available in the vSphere API known as “MoveIntoFolder.” We can see some additional information about this method in the VMware Code API Explorer: MoveIntoFolder Method

I have created and shared a script on the PowerCLI Community repository and the VMware Code Sample Exchange which takes that “MoveToFolder” and wraps it in an advanced function we can call with: Move-DatastoreCluster

Example Usage

The script will need to be, what’s known as, dot sourced so that the advanced function is available in our current PowerShell session. From that point we will use the ‘DatastoreCluster’ parameter to pass a Datastore Cluster and the ‘Destination’ parameter to pass a folder.

Putting this altogether looks a bit like the following:
Move-DatastoreCluster Example Code


PowerCLI is a great tool to use when automating VMware environments. In the case of Datastore Clusters, we can actually use PowerCLI to perform tasks which aren’t available in the vSphere Client! The Move-DatastoreCluster script has been shared and presents an advanced function, of the same name, which allows us to move Datastore Clusters between the available folders.

If this is a function you’d like to see added to PowerCLI, head out to the public feature request site and upvote the following idea: Enhancement for moving inventory items Datastore Cluster