Home > Blogs > VMware PowerCLI Blog

What PowerCLI Version Am I On Anyways?

When PowerCLI was converted to modules, it introduced the ability to pick and choose which modules are loaded. Taking it a step further, it also allowed users to specify which versions of those modules are loaded. Historically, PowerCLI was released as one large ‘bundle’ of modules, and was not a great release practice. This meant that even though most modules were not touched, we were still required to go through our release processes to get them out the door. This is not scalable when trying to get features to you more frequently.

With modules in the Powershell Gallery, we can now release individual modules asynchronously from other modules. The first release to really take advantage of that is PowerCLI 6.5.2. For those whom have already updated their VMware.PowerCLI module from the Microsoft PowerShell Gallery, you noticed there were only 3 modules which were updated and needed to be downloaded.

The Better Way

In prior releases, we could use the ‘Get-PowerCLIVersion’ cmdlet and receive a high-level look at the overall PowerCLI version which was installed. Previously, our versioning scheme was not supported in PowerShell, so it took a cmdlet to print the version out (Example: VMware PowerCLI 6.5 R1). That is gone now. We’ve made the change to semantic versioning in 6.5.1. This means there will be no more R1, R2, or R3 releases!

Starting with PowerCLI 6.5.2, the process to get module versions has changed. Running the ‘Get-PowerCLIVersion’ cmdlet now results in a warning message indicating that it is deprecated and to use the ‘Get-Module’ cmdlet instead.

Example of the deprecation notice for Get-PowerCLIVersion

Using Get-Module

There are a couple ways to use the ‘Get-Module’ cmdlet to help us determine our versioning. The reason for that is because the ‘Get-Module’ cmdlet only shows the modules which have been imported.

The first way is to get the overall PowerCLI version, which is dependent on the ‘VMware.PowerCLI’ module. We can determine the version by first importing the module (if it’s not already imported) and then running the following command:
Get-Module -Name VMware.PowerCLI | Select-Object -Property Name,Version

Example: Obtaining the version of the VMware.PowerCLI module

From the above example, we can see that we’re using PowerCLI version 6.5.2.

Another way is to just reference the modules which have been loaded automatically. I have an example where we connect to our vCenter Server and then run the following command to find the versions of all the PowerCLI modules which are in-use:
Get-Module -Name VMware.* | Select-Object -Property Name,Version

Example: Obtaining the version of PowerCLI when using module autoloading

From the above example, we see that we’re only using a single PowerCLI module and it happens to be versioned at 6.5.2.

Running a couple additional, random, commands, we re-run the above command and see there’s now a bit more of a mix amongst our loaded modules.

Example: Obtaining the version of active PowerCLI modules

Summary

The new method to obtain what version of PowerCLI you’re using is through the ‘Get-Module’ cmdlet. This update was made for many reasons. This new method takes advantage of how our the PowerCLI modules can be loaded independently of each other on an as needed basis. It also takes advantage of how the PowerCLI module releases can now be done asynchronously from each other. Lastly, since we’ve changed the PowerCLI versioning over to align with the standard PowerShell versioning, there’s no need for a custom cmdlet anymore!

If you’re using ‘Get-PowerCLIVersion’ in your scripts or modules, make sure you’re aware of this and update your resources to reflect this change!

Updating PowerCLI through the PowerShell Gallery

PowerCLI 6.5.2 has been released! This is the second release of PowerCLI to the PowerShell Gallery, so it’s time to figure out how to update your PowerCLI versions to the latest and greatest.

We’ll cover a couple scenarios:

  • Updating from PowerCLI 6.5.1, installed online from the PowerShell Gallery
  • Updating from PowerCLI 6.5.1, installed offline from the PowerShell Gallery
  • Updating from PowerCLI 6.5 R1 or prior

Updating from PowerCLI 6.5.1, Online

This will be the easiest update process PowerCLI has ever offered! Open a PowerShell session, type the following command:
Update-Module -Name VMware.PowerCLI

Update Module Example

That’s it, you’re now running the latest and greatest PowerCLI release!

However, if you happen to have run into the following error it’s possible that PowerCLI was installed by the offline method:
Update-Module : Module ‘VMware.PowerCLI’ was not installed by using Install-Module, so it cannot be updated.

There’s two main ways to resolve this:
Option 1. Remove the PowerCLI modules from where they currently reside
1a. Run the following command:
Get-Module VMware.* -ListAvailable
1b. There should be a ‘Directory’ label at the top of the response. Browse to that directory and remove all the directories starting with ‘VMware.*’

Example Usage of Get-Module

1c. Perform the following command:
Install-Module -Name VMware.PowerCLI -Scope CurrentUser

Option 2. Use the force… And by that, I mean perform the Install-Module command with the ‘Force’ parameter
2a. Perform the following command:
Install-Module -Name VMware.PowerCLI -Scope CurrentUser -Force

Updating from PowerCLI 6.5.1, Offline

This process will work exactly the same as the installation process.

1. From a computer that has internet access, run the following command:
Save-Module -Name VMware.PowerCLI -Path C:\Path\To\Desired\Folder
2. Take the downloaded modules and make them available to the offline system
3. Copy and replace the individual PowerCLI module folders to the location where the prior modules were placed.

Copying over the PowerCLI modules after saving them locally

Updating from PowerCLI 6.5 R1 or prior releases

If you happen to be running an older version of PowerCLI which involved an MSI installer, we can verify that by running the following command:
Get-Module VMware* -ListAvailable

Example on showing a list of available PowerCLI modules

If the majority of PowerCLI modules are versions listed at 6.5.0 or older, as shown above, proceed through the following steps.

PowerCLI 6.5 R1 (or older) Uninstallation Steps:
1. Uninstall PowerCLI through the Control Panel
2. Browse to the following directory: C:\Program Files (x86)\VMware\Infrastructure\
3. If there is a ‘vSphere PowerCLI’ directory, delete it

Uninstalling Prior PowerCLI Versions

PowerCLI 6.5.2 Online Installation
This works exactly the same as how the installation did for PowerCLI 6.5.1.

Within a PowerShell session, type the following command: $PSVersionTable

PSVersion Table Sample Output

If the PSVersion is a Value of 5.0 or above:
1. Run the following command:
Install-Module -Name VMware.PowerCLI –Scope CurrentUser
2. If asked to update ‘NuGet Provider’, choose ‘Y’ to install and import the newer version.
3. If asked to ‘install modules from an untrusted repository’, choose ‘Y’ to accept.

Install Module usage to PowerCLI 6.5.2

If the PSVersion is a Value of 4.x or 3.x:
1. Install a current version of PowerShellGet through one of the following two options:
1a. Install Windows Management Framework 5.1
1b. Install PackageManagement PowerShell Modules
2. Run the following command:
Install-Module -Name VMware.PowerCLI –Scope CurrentUser
3. If asked to update ‘NuGet Provider’, choose ‘Y’ to install and import the newer version.
4. If asked to ‘install modules from an untrusted repository’, choose ‘Y’ to accept.

PowerCLI 6.5.2 Offline Installation
1. From a computer that has internet access, run the following command:
Save-Module -Name VMware.PowerCLI -Path C:\Path\To\Desired\Folder
2. Take the downloaded modules and make them available to the offline system
3. Copy and replace the individual PowerCLI module folders to one of the following locations:
3a. Local User Usage: $home\Documents\WindowsPowerShell\Modules
3b. All User Usage: $pshome\Modules

Example file structure for an offline PowerCLI Installation

The PowerCLI Installation Walkthrough Video also works in this scenario too. However, following the instructions in the video will now result in PowerCLI 6.5.2 being installed:

New Release: VMware PowerCLI 6.5.2

The past couple releases have introduced some new and exciting modernizations for PowerCLI. We’ve moved from Snapins to Modules, leaving behind registry settings and the need for an installer and making packaging much easier. We then introduced you to PowerCLI installation through the Microsoft PowerShell Gallery, making installation and updates a single command.

All of these lead up to us delivering more frequent releases and more timely features and bugfixes. Only three months ago, we introduced PowerCLI 6.5.1, and today we’re delivering 6.5.2, cutting our release time in half from the past. We still have a lot of work to do on our processes, but we look forward to delivering frequent, high quality releases of the best automation library for VMware!

PowerCLI 6.5.2 has some great improvements. They come in three main areas:

  • Addition of the ‘InventoryLocation’ parameter to the following cmdlets: Move-VM, Import-VApp, New-VApp
  • Ability to mount a Content Library sourced ISO with the New-CDDrive cmdlet
  • Updated Support Around Experimental Features

Let’s take a closer look at each of these.

New Parameter: InventoryLocation

The main purpose of the ‘InventoryLocation’ parameter is to specify a folder the VM or vApp should be placed during their related actions. The expected input for this parameter is a type of ‘FolderContainer’. Previously, the only option was ‘Destination’ and it accepted a folder, ESXi host, cluster, or resource pool. The issue was only one item could be specified at a time. Therefore, this addition is nice because it reduces the total number of steps needed to either move a VM between vCenter Servers or when deploying a new VM/vApp.

First example, moving a VM between vCenter Servers. By default, the VM would be moved to the root of the Datacenter in the ‘VMs and Templates’ view. Technically, it would be moved to the ‘vm’ folder but that’s hidden from the GUI view. This new parameter allows us to skip the follow-up ‘Move-VM’ command and place the VM in the proper folder at time of the migration.

Cross vCenter vMotion Example using Inventory Location Parameter

Second example, creating a new VM by importing a vApp. As with the previous example, this cuts down the steps in deploying this VM and streamlines the process.

Import-VApp example while using the Inventory Location parameter

Using Content Library Sourced ISOs

The ‘New-CDDrive’ cmdlet has a new parameter by the name of ‘ContentLibraryIso’. This allows us to mount an ISO which has been presented through vSphere’s Content Library. Here’s an example:

Example usage of the New-CDDrive cmdlet and Content Library ISOs

vSphere’s Content Library is a great resource and I’m really happy to be able to take better advantage of it through PowerCLI!

Experimental Feature Updates

If you’ve had the chance to read through our documentation, perhaps you’ve noticed a couple of the features or parameters which were marked as experimental. Several of these have been tested and we have been able to remove the functionality’s ‘experimental’ messaging.

Some Examples:

  • Set-HardDisk -ZeroOut: This parameter can be used to zero out a disk when the PowerCLI session is connected directly to the ESXi host.
  • New-HardDisk -AdvancedSetting: The experimental part of this parameter was centered around the Storage Distributed Resource Scheduler (SDRS) rule association.
  • New-VM -AdvancedSetting: The experimental part of this parameter was centered around the SDRS (SDRS) rule association.
  • Install-VMHostPatch: The whole cmdlet was experimental and has been approved for supported usage.

Summary

PowerCLI 6.5.2 is the first of our change to having more frequent releases. While these iterative releases may not be as packed full of new features as all the prior releases, we are able to provide new functionality and resolve any issues faster than prior versions. Some proof of that is the addition of the ‘InventoryLocation’ parameter to several cmdlets, the ‘ContentLibraryIso’ parameter to the New-CDDrive cmdlet, and taking several features and cmdlets from experimental to supported!

Don’t wait, Update-Module today!

Update Module Example

For information on the Microsoft PowerShell Gallery update process, see the following blog: Update PowerCLI From the PowerShell Gallery

For more information on changes made in VMware PowerCLI 6.5.2, including improvements, security enhancements, and deprecated features, see the VMware PowerCLI Change Log. For more information on specific cmdlets, see the VMware PowerCLI 6.5.2 Cmdlet Reference.

PowerCLI at VMworld US 2017

VMworld 2017

It’s that time of year again, VMworld US time! There is a whole slew of PowerCLI and automation based sessions and events going on this year that you should be excited for. Hopefully you are already registered and have started adding these sessions to your schedule. If you haven’t, the countdown has begun and this year is not one to be missed!

The following is going to break down the breakout sessions, group discussions, vBrownbag Community sessions, hands-on labs, and a very special event returning for its second year!

Breakout Sessions

Monday, Aug 28, 11:30 a.m. – 12:30 p.m. – Ariel Sanchez & Edgar Sanchez
SER2077BU – Achieve Maximum vSphere Stability with PowerCLI Assisted Documentation: From Buildout to Daily Administration: vSphere is the core product on which all other VMware technologies depend on. Adhering to the HCI, whether inbox or partner async, defining, documenting and verifying host and vCenter settings are critical for vSphere stability. In this session, we will talk about the experience and lessons learned of managing enterprise environments in a multi-vendor ecosystem, controlling settings drift when scaled to hundreds of hosts using PowerCLI, and producing relevant documentation that could not be produced otherwise.

Tuesday, Aug 29, 11:30 a.m. – 12:30 p.m. – Ragavendra Kumar & Devaraj Ramanjaneya
SER2972BU – Troubleshooting 101 for vSphere 6.x: Join us for an overview of 1) understanding the methodology of problem solving 2) recognizing the powerful troubleshooting tools available in VMware vCenter Server & ESXi server and 3) explore log files that help to diagnose and solve problems. We will also focus on how to make your day to day life easier by using vRealize Log Insight and bring automation using vSphere CLI and PowerCLI in your environment.

Tuesday, Aug 29, 5:30 p.m. – 6:30 p.m. – Dale Coghlan & Nicholas Bradford
NET2119BU – PowerNSX – Bringing the power of PowerCLI to VMware NSX for vSphere: PowerNSX is a PowerShell module that abstracts the VMware NSX for vSphere API to a set of easily used PowerShell functions. Working seamlessly with VMware PowerCLI, PowerNSX brings unprecedented power and flexibility to administrators of VMware NSX for vSphere environments. In this session, you will learn what PowerNSX is and the flexibility and control that it can bring.

Wednesday, Aug 30, 11:30 a.m. – 12:30 p.m. – Kyle Ruddy & Jake Robinson
SER2480BU – VMware PowerCLI 101: Becoming Your Organization’s Superhero: Automate any task in your VMware datacenter with PowerCLI: Kyle and Jake will demonstrate the “power” in VMware PowerCLI, taking you on the journey to make VMware datacenter management fun and efficient. You’ll learn how to craft information-packed reports of your datacenter, automate some of the most daunting GUI tasks, and connect with a community of thousands of PowerCLI users.

Wednesday, Aug 30, 2:30 p.m. – 3:30 p.m. – Luc Dekens & Alan Renouf
SER1875BU – The Power Hour: VMware PowerCLI 10th Birthday Edition: In this special edition of the Power Hour, marking the 10th birthday of VMware PowerCLI, Alan and Luc will not only bring you new features and deep dives but also show how far VMware PowerCLI has come and how it has evolved over the past 10 years. The deep dives will extend far beyond vSphere administration. The examples will demonstrate how to manage your VMware products with VMware PowerCLI in a consistent and user-friendly way.

Wednesday, Aug 30, 4:00 p.m. – 5:00 p.m. – Alan Renouf & Jake Robinson
SER2529BU – VMware PowerCLI What’s New: The Next Evolutionary Leap Is Now: Get the latest scoop on PowerCLI features and capabilities with Alan and Jake! Learn about the latest improvements of PowerCLI Installation and Upgrade using the PowerShell Gallery. We’re always adding new cmdlets to PowerCLI, and the latest release does not disappoint. We’ll share the breadth of everything new you can do with PowerCLI including added vCenter functionality, vSAN functionality and more. If all this wasn’t enough, we’ll also give an overview of multi-platform support and a technical preview of upcoming features.

Thursday, Aug 31, 1:30 p.m. – 2:30 p.m. – Scott Driver & Kyle Ruddy
SER2614BU – PowerCLI 201: Getting More Out of VMware PowerCLI: Join us as we walk attendees through this demonstration heavy session and show how to make your code run faster, how to access the vSphere APIs for better control within the code, and utilize the features of the framework to script even the most daunting of tasks.

Group Discussions

Tuesday, Aug 29, 1:00 p.m. – 2:00 p.m. – Kyle Ruddy & Jake Robinson
SER3041GU – VMware PowerCLI: Join this discussion to learn about and discuss PowerCLI with Product Management, Technical Marketing, and peers!

Wednesday, Aug 30, 10:00 a.m. – 11:00 a.m. – Kyle Ruddy & Jase McCarty
STO1119GU – Automating vSAN Deployments at Any Scale: Join us to discuss some of the mechanisms and workflow requirements when deploying VMware vSAN in small or large deployments.

VMTN vBrownbag Community Sessions

Monday, Aug 28, 1:00 p.m. – 1:15 p.m. – Scott Driver
VMTN6601U – No Money, No Problem – Start Automating with PowerCLI: Do you build or do you buy? It’s a classic IT question, but for many, it comes down to budget. If you don’t have a budget, and all of the Open Source DevOps tools have you scratching your head, no worries! We will discuss some real-world approaches and actual operational examples that will help you get started on automating the management of your virtual machine and virtual infrastructure environments by harnessing the vast potential of PowerCLI.

Wednesday, Aug 30, 9:30 a.m. – 10:00 a.m. – Ariel Sanchez & Edgar Sanchez
VMTN6692U – Estabilidad en vSphere con FOSS/PowerCLI: This is the Spanish, version of the VMworld accepted talk “SER2077BU – Achieve Maximum vSphere Stability with PowerCLI Assisted Documentation: From Buildout to Daily Administration” with the same presenters doing the same content but in spanish!

Monday, Aug 28, 3:00 p.m. – 3:15 p.m. – Russell Hamker
VMTN6637U – Linked Clones with PowerCLI: Talk about the power of Linked Clones with PowerCLI. I will talk about the use cases that my company uses it for and for a few other use cases. This includes accelerating DevOps, spinning up Desktop VMs for uses when needed, and using Linked Clones to duplicate SQL servers for testing.

Tuesday, Aug 29, 11:30 a.m. – 11:45 a.m. – Justin Sider
VMTN6618U – PowerCLI administration with a Windows Docker Image: As a Windows administrator I continue to find ways to help improve my daily life as a PowerShell and VMware PowerCLI techie. One of the problems I consistently fight is my local machine configuration and managing the versions of my installed software. I recently transitioned to using a Windows Docker image to use as my runtime script execution environment. It allows me to customize multiple environments, CLEAN environments, quick deployment, great for remote sites, and its native Windows with full PowerShell.

Wednesday, Aug 30, 10:45 a.m. – 11:00 a.m. – Anthony Hook
VMTN6684U – Discover PowerCLI Without Documentation: Discover how to use PowerCLI and grab information based on a few simple commands. Learn how to figure out what kind of data is returned, and how to find what is available to you.

Wednesday, Aug 30, 11:45 a.m. – 12:00 p.m. – Brian Bunke
VMTN6639U – Vester: vSphere Config Management with PowerCLI: Did your predecessors and coworkers leave all of your clusters/hosts/VMs/etc. with uniform settings? No? Vester uses PowerCLI to report on differences, optionally fix them, and store your desired settings in a config file for future reference.

Wednesday, Aug 30, 1:30 p.m. – 1:45 p.m. – Jorge Torres
VMTN6634U – Como empezar con PowerShell/PowerCLI: Spanish Session – Join me to learn how to initiate and some first steps when learning PowerShell/PowerCLI. I’d like to encourage others to jump into the PowerCLI world and realize its great value.

Thursday, Aug 31, 11:45 a.m. – 12:00 p.m. – Justin Sider
VMTN6632U – XesterUI – A User Interface for Vester vSphere configuration validation: XesterUI is a simplistic web interface that completely wraps Vester. Simple to deploy and configure, this tool can be shared amongst a team or group of system administrators, preventing everyone from needing to install and run command line tests. I’ll walk through a basic scenario of how quick and easy this tool can resolve configuration drift on a vCenter implementation.

TAM Customer Central

Tuesday, Aug 29, 11:30 a.m. – 11:45 a.m. – Kyle Ruddy & Pamela Norris
TAM4528U – Get Started Automating Your Horizon Environment with PowerCLI: Come one, come all, and see how PowerCLI 6.5.1 provides Horizon administrators with the ability to automate their Horizon 7 environments. During this session packed full of interactive demos, you will see how the latest features and functionality can help automate daily tasks with some simple and reproducible commands. With the promise of some great conversations to be had!

Meet The Expert Sessions

Ever wanted to have a chance to sit down with your favorite automation guru? VMworld US is going to give you that chance! Make sure to block out time to sit down with our experts!

Host Session Scheduled Time Table
William Lam MTE4724-SER Monday, Aug 28, 2:15 p.m. to 3:00 p.m. Table 4
Wednesday, Aug 30, 11:15 a.m. to 12:00p.m.
Alan Renouf MTE4723-SER Tuesday, Aug 29, 1:15 p.m. to 2:00 p.m. Table 4
Wednesday, Aug 30, 1:15 p.m. to 2:00p.m.
Thursday, Aug 31, 1:45 p.m. to 2:30p.m.
Kyle Ruddy MTE4722-SER Monday, Aug 28, 5:15 p.m. to 6:00 p.m. Table 4
MTE4721-SER Tuesday, Aug 29, 2:15 p.m. to 3:00p.m.
Wednesday, Aug 30, 2:15 p.m. to 3:00p.m.
Thursday, Aug 31, 11:45 a.m. to 12:30p.m.

Hands-On Lab

SPL181105U – vSphere Automation: 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.

Hands-On Lab – Expert Led Workshop

Thursday, Aug 31, 1:30 p.m. – 3:00 p.m. – Kevin Steil
ELW181105U – vSphere Automation – PowerCLI Workshop: In this expert led workshop, 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.

VMware Code Hackathon

Monday, Aug 28, 8:00 p.m. – 12:00 p.m. – VMware Code
VMTN6722U – Hackathon Event

The VMware Code Hackathon was probably my favorite event from VMworld last year. This event encouraged any VMworld attendee to come, join a team, and complete some form of project or challenge. Attendees varied from vSphere beginners to highly skilled programmers. Everyone had a blast, there were some terrific giveaways, special guests, and so forth.

This year, the Hackathon returns and it is only getting better! I can’t reveal any of the secrets planned, but it is certainly going to be one of the best evening events that week!

Additional Information: VMware Code Blog – VMworld Hackathon is Back

Spotlight on the New DRS Groups and VM-Host Rule Cmdlets!

We’re kicking off the first in a series of blog posts taking an in-depth look at some of the new cmdlets that were made available with the PowerCLI 6.5.1 release. This first post is going to be covering the cmdlets targeted at managing DRS groups and their associated rules.

These new cmdlets are as follows:

  • Get-DrsClusterGroup
  • New-DrsClusterGroup
  • Set-DrsClusterGroup
  • Remove-DrsClusterGroup
  • Get-DrsVMHostRule
  • New-DrsVMHostRule
  • Set-DrsVMHostRule
  • Remove-DrsVMHostRule

If you’ve never used DRS groups and DRS affinity rules or don’t know what they are, these are a way to control which VMs are able to exist on which hosts. This control is leveraged through either affinity or anti-affinity rules that are configured at the cluster level. These rules are configured between groupings of VMs and groupings of hosts. These rules also have types, which basically describes how the enforcement should work. The types are: Must Run On, Should Run On, Must Not Run On, Should Not Run On

Please see the documentation for more information about: DRS Affinity Rules

Taking A Closer Look – A Use Case Demonstration

We have been given a lab environment and our end result is to have the even numbered App VMs run on the even numbered hosts whenever possible, and likewise with the odd numbered VMs and hosts.

First, a look at the lab environment:

  • 1 Cluster
  • 4 Hosts
  • 50 VMs

Environment Setup

We’ll start by taking a look at the DRS Cluster Group cmdlets. These are used in order to create, manage, and remove VM and host based DRS groups. These cluster groups are then referenced by the DRS VM-Host affinity rules, which we’ll discuss in a bit.

Let’s create the first host DRS group, which will be for the odd numbered hosts. This can be done with the ‘New-DrsClusterGroup’ cmdlet while specifying a name, the cluster, and the desired hosts. A command for our sample environment looks like this:

New-DrsClusterGroup -Name HostsOdd -Cluster Demo -VMHost esx01.corp.local,esx03.corp.local

Creating a DRS group

We’ll repeat a similar process for the even hosts, only this time we’ll store the cluster and desired hosts in their own variables:
Creating a DRS group

We now have the required host DRS groups, so we can move forward and create the VM DRS groups. These are created with the same ‘New-DrsClusterGroup’ cmdlet, except we’ll now use the VM parameter and specify the VMs for each group.

Starting again with our odd numbered VMs, we’ll use the following command:

New-DrsClusterGroup -Name VMsOdd -Cluster $cluster -VM app01,app03,app05

Creating a DRS group

If you’ll notice, that’s nowhere close to all of the necessary odd numbered VMs. We’ll now make use of the ‘Set-DrsClusterGroup’ cmdlet to add the remaining VMs (which I’ve already stored into a variable). This cmdlet also requires usage of either the ‘Add’ or ‘Remove’ parameter in order to specify what kind of modification is being requested.

The command to add the remaining odd system should be similar to the following:

Set-DrsClusterGroup -DrsClusterGroup VMsOdd -VM $VMsOdd –Add

Updating a DRS group

We’ll repeat a similar process for the even VMs’ DRS group:
Creating a DRS group

Before moving on to creating the VM-Host affinity rules, let’s review the DRS groups we’ve created to this point with the ‘Get-DrsClusterGroup’ cmdlet.
Displaying the DRS Groups

This cmdlet also has a couple parameters to help gain additional information. The ‘Type’ parameter can be used to specify whether to return VM groups or host groups. The ‘VM’ and ‘VMHost’ parameters can be used to only return DRS groups belonging to that VM or host.

Some examples of these parameters in use:
Filtering the list of DRS groups

Moving on to the creation of the rules… We’ll be using the ‘New-DrsVMHostRule’ cmdlet along with several parameters. These parameters will be ‘Name’, ‘Cluster’, ‘VMGroup’, ‘VMHostGroup’, and ‘Type’. Most of those should be self-explanatory, but ‘Type’ may not be. Thanks to tab complete, we’ll see that the type options are ‘MustRunOn’, ‘ShouldRunOn’, ‘MustNotRunOn’, and ‘ShouldNotRunOn’ and apply to how the rule is enforced against the cluster.

Remembering that our goal is to have the even VMs run on the even hosts whenever possible, we’ll issue the following command:

New-DrsVMHostRule -Name 'EvenVMsToEvenHosts' -Cluster $cluster -VMGroup VMsEven -VMHostGroup HostsEven -Type ShouldRunOn

Creating a VM-Host Rule

We’ll do a similar command for the odd rule:
Creating a VM-Host Rule

Our objective should be complete and we can verify that by using the ‘Get-DrsVMHostRule’ cmdlet. The output should be similar to the following:
Displaying VM-Host Rules

These VM-Host rules can also be modified once they’ve created with the ‘Set-DrsVMHostRule’ cmdlet. This cmdlet has the ability to rename the rule, enable or disable it, and modify either the VMGroup and/or the VMHostGroup.

The rules can easily be disabled using the following command:

Get-DrsVMHostRule | Set-DrsVMHostRule -Enabled $false

Modifying VM Host Rules

This environment happens to be a lab, so before wrapping up this post we should probably clean it up. We can do this while utilizing the ‘Remove-DrsClusterGroup’ and ‘Remove-DrsVMHostRule’ cmdlets. The commands could look like the following:

Remove-DrsVMHostRule -Rule EvenVMsToEvenHosts,OddVMsToOddHosts
Get-DrsClusterGroup | Remove-DrsClusterGroup

Cleaning up the lab environment

Summary

These eight new cmdlets are a terrific addition to the PowerCLI 6.5.1 release. They are also a great compliment to the already existing DRS cmdlets! Start using them today and let us know your feedback!

PowerCLI 6.5.1 Installation Walkthrough

We released PowerCLI 6.5.1 two weeks ago and the response has been incredible! The VMware.PowerCLI module is closing in on 4,000 downloads from the PowerShell Gallery and we’ve received a ton of good feedback.

There seems to be quite a few questions and comments over this new installation method so I created a walkthrough video to illustrate the process for PowerShell version 5.0 as well as for versions 3.0 and 4.0. We’ve also collected the most common errors and issues during the installation process and included troubleshooting steps for those below.

Walkthrough Video

Common Troubleshooting Steps

If there happens to be an issue during the installation process, here’s a couple of the top tips we have seen on working around them:

  • The process cannot access the file ‘C:\Users\…\AppData\Local\Temp\…’
    • Ensure previous versions of PowerCLI are uninstalled and all PowerShell sessions are closed.
    • Verify the file isn’t being blocked by an antivirus software.
  • A command with name ‘verb-noun’ is already available on this system.
    • This is due to a module already available on the system containing that cmdlet. The more common example modules include FailoverClusters and HyperV.
    • Append “-AllowClobber” to the Install-Module command line.
      Example: Install-Module –Name VMware.PowerCLI –Scope CurrentUser –AllowClobber
  • No match was found for the specified search criteria and module name ‘VMware.PowerCLI’
    • This could be due to a lack of connectivity to the PowerShell Gallery.
    • If a proxy can be used, the “Install-Module” cmdlet can configure proxy connectivity with the “Proxy” and “ProxyCredential” parameters.
      Example: Install-Module –Name VMware.PowerCLI –Scope CurrentUser –Proxy ‘http://my.proxy.company.com’
  • Could not get response from query ‘https://www.powershellgallery.com/api/v2/package/VMware.VimAutomation.Core/…’
    • This warning is just indicating there is an issue establishing connectivity to the PowerShell Gallery. Retry the installation at a later point in time and it should succeed.

Summary

We are really excited about this release and what this means for the future of PowerCLI! Upgrade to PowerCLI 6.5.1 today, and keep that feedback rolling in!

Welcome PowerCLI to the PowerShell Gallery – Install Process Updates

PowerCLI 6.5.1 has been released and in this release we have made some big changes to the way you install and keep up to date with PowerCLI! This update was all based around Microsoft PowerShell deployment models, listening to you, the customer and ensuring we are making the changes to provide the best PowerShell product going forward.

As of PowerCLI 6.5.1, you no longer have a MSI file to download and install. You can now install directly from the PowerShell Gallery! This update streamlines the install process in multiple ways and allows module based features which PowerShell users will be used to from other PowerShell based additions.

What does this mean for you?

PowerCLI being on the PowerShell Gallery means there are some changes that users should be aware of. The first big change, there is no more MSI to perform the install and therefore you don’t download it from the VMware website!

The install is done completely through PowerShell itself using the PowerShell Gallery via PowerShellGet. This means also means the other items which used to be installed by way of the MSI won’t be installed automatically. These things include the PowerCLI desktop shortcuts and the User Guide.

There are two ways in which you may install PowerCLI with this new method, online and offline. Let’s take a look at how to perform these methods.

Getting Started

The first step in moving to this new release is to uninstall any prior versions of PowerCLI which may be installed on the system by the old MSI installer, this is needed to move to the new distribution model.

Uninstalling Prior PowerCLI Versions

It is also worth checking to ensure the “PowerCLI” folder has been removed from the following directory: C:\Program Files (x86)\VMware\Infrastructure\

With the prior version of PowerCLI uninstalled, it’s time for the install!

Online Installation From a Computer with an Internet Connection

For the online install, start by confirming access to PowerShell Gallery and being able to find the PowerCLI module. This can be done by running the following:

Find-Module -Name VMware.PowerCLI

Find-Module Output for PowerCLI

Note: If you have not accessed the PowerShell Gallery before, or perhaps have an out of date version of NuGet, you may receive a message indicating there is a missing or out-of-date NuGet provider. NuGet is a Package Management provider. These are primarily used to install, upgrade, configure, and/or remove software in an automated fashion. To accept the installation of a proper version of NuGet, hit “Y”.

We will now make use of the Install-Module cmdlet to make PowerCLI actually available on the local system. This can be done with the following:

Install-Module -Name VMware.PowerCLI –Scope CurrentUser

You will notice we’re only installing it for the current user, we do this because it doesn’t require admin access! If you would like it available for all users of the computer, your PowerShell session will have to be running as an administrator, and PowerCLI will automatically be installed for all users by changing the Scope parameter to AllUsers.

Install-Module usage

Success! We now have the PowerCLI modules installed and available locally!

Offline Install of PowerCLI to a Computer Without an Internet Connection

The following method should be used to install PowerCLI through the PowerShell gallery for those systems which do not have access to the internet. You will need at least one system that has internet access and a way to move the files to the target computer.

While on a system that has internet access, we will find the PowerCLI module with the same command we ran above:

Find-Module -Name VMware.PowerCLI

Then we can download the module for offline consumption with the following command:

Save-Module -Name VMware.PowerCLI -Path C:\Path\To\Desired\Folder

Save-Module Output

At this point, we’ll want to copy those downloaded folders and place them on the system without internet access in a location where PowerShell can find them, this is the modules folder and can be confirmed by typing $ENV:PSModulePath at the powershell prompt.

Local User: $home\Documents\WindowsPowerShell\Modules
All Users: $pshome\Modules

Using PowerCLI

One of the great enhancements in PowerCLI 6.5.1 means we no longer need to load the modules into the PowerShell session as we may have done in the past, as soon as the modules are loaded into the module folder PowerShell will automatically be aware of their existence and you will find the cmdlets registered with the PowerShell session. Normal PowerShell behaviour meanst that as soon as you use the first cmdlet the PowerCLI module will be loaded as needed.

But what about the nice PowerCLI Welcome message and other functions which existed to make PowerCLI easier to use when we launched the old desktop icon?

First, we can mimic the desktop shortcuts by simply running:

Import-Module VMware.PowerCLI

Import-Module VMware.PowerCLI Output

Please note the warning message about joining the Customer Experience Improvement Program (CEIP). We recommend enabling CEIP, as it’s greatly helps us improve our products! In order for the message to not appear, you either have to enable or disable CEIP by way of the Set-PowerCLIConfiguration cmdlet.

The other option to load the cmdlets, simply use the cmdlets as you normally would. The modules will auto-populate as necessary!

Here’s an example of using a new PowerShell session and connecting to a vCenter Server:

PowerCLI Autoloading Example

We can see the session begins without any PowerCLI modules being imported. After typing in the Connect-VIServer cmdlet (tab complete is fully operational as well), we can see the VMware.VimAutomation.Core module has been imported automatically! The other modules won’t be imported until they’re referenced.

Re-Creating The Desktop Shortcut

I know there are quite a few fans of the Desktop shortcut, so I’ll briefly describe how to set that up. First, create a shortcut that points to the PowerShell executable and place it on the desktop. Next, right click the newly created desktop shortcut and select properties. You should find yourself on the “Shortcut” tab. Enter the following values:

Target: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noe -c "Import-Module VMware.PowerCLI"
Start In: C:\
Shortcut Key: None
Run: Normal Window
Comment: Launch VMware PowerCLI

In the end, we should have something quite similar to the following:
Recreating the PowerCLI Desktop Shortcut

Summary

This new install method is a very exciting improvement for PowerCLI. As seen above, this definitely streamlines the process of getting PowerCLI installed and accessible!

To find out more about the other fantastic improvements that are available with VMware PowerCLI 6.5.1, please see the following blog: New Release – PowerCLI 6.5.1

New Release: PowerCLI 6.5.1

It’s PowerCLI release day and this is a significant one! This new release of PowerCLI is versioned at 6.5.1 rather than what you probably expected which would be 6.5 R2 (following on from our last release). We have made this change in order to fall in line with the best practices for being used in the PowerShell Gallery!

New Features

First and foremost, the largest update to this version of PowerCLI is regarding how the installation process has changed. As of this release, you no longer have an MSI file to download and install. You can now install PowerCLI directly from the PowerShell Gallery! This update streamlines the install process in multiple ways and allows module based features which PowerShell users will be used to from other PowerShell based additions.

For a detailed walkthrough on this new installation process, please see this blog post on Installing PowerCLI from the PowerShell Gallery.

The modules have also been updated to support the PowerShell auto-loading process. This allows PowerShell to automatically import the necessary modules in order to process the desired entered cmdlet. A good example would be to open a new PowerShell session, enter “Connect-VIServer” and then populate the parameters as you normally would. You’ll be pleasantly surprised to see the cmdlet working properly without any other input for cmdlets required.

PowerCLI cmdlet Autoload Process

The Core module has had some notable updates. We listened to the feedback and have added several new cmdlets that create, manage, and remove DRS cluster groups and VM/Host rules. The new cmdlets are as follows:

  • Get-DRSClusterGroup
  • New-DRSClusterGroup
  • Set-DRSClusterGroup
  • Remove-DRSClusterGroup
  • Get-DRSVMHostRule
  • New-DRSVMHostRule
  • Set-DRSVMHostRule
  • Remove-DRSVMHostRule

One other major change has happened to the main vSphere module (vim.automation.core module) concerning the Site Recovery Manager (SRM) cmdlets. The SRM cmdlets have been removed from the Core module and a new SRM module has been created. The new module is named VMware.VimAutomation.Srm and features updated cmdlets that enable users to interact with the API views for the SRM 6.5 API!

Speaking of APIs, there are a couple other modules which have been updated to work with the most current APIs. The vR Ops module has been updated to work with the views for the vR Ops 6.5 API. The Horizon module has also been updated to work with the views for the Horizon View 7.1 API. The Storage module has also been updated to work with the views for the latest vSAN 6.6 API.

Last, but certainly not least, the Storage module has received some tremendous updates as well. Many new cmdlets have been added to interact with vSAN’s iSCSI features. The cmdlets include managing an iSCSI initiator group and/or an iSCSI target, managing a resource’s access which are not part of the vSAN cluster, and controlling a vSAN sourced iSCSI LUN. The new cmdlets are as follows:

  • Get-VsanIscsiInitiatorGroup
  • New-VsanIscsiInitiatorGroup
  • Set-VsanIscsiInitiatorGroup
  • Remove-VsanIscsiInitiatorGroup
  • Get-VsanIscsiTarget
  • New-VsanIscsiTarget
  • Set-VsanIscsiTarget
  • Remove-VsanIscsiTarget
  • Get-VsanIscsiInitiatorGroupTargetAssociation
  • New-VsanIscsiInitiatorGroupTargetAssociation
  • Remove-VsanIscsiInitiatorGroupTargetAssociation
  • Get-VsanIscsiLun
  • New-VsanIscsiLun
  • Set-VsanIscsiLun
  • Remove-VsanIscsiLun
  • Get-VsanStat
  • Start-VsanDiskFormatUpdate
  • Get-VSANView

The Storage module has received some updates that are not vSAN related as well. The other changes are around storage policy based management (SPBM) cmdlets. These cmdlets are:

  • Start-SpbmReplicationPromote
  • Start-SpbmReplicationTestFailover
  • Stop-SpbmReplicationTestFailover

Summary

As evidenced above, PowerCLI 6.5.1 is a pretty big release. PowerCLI being available exclusively through the PowerShell Gallery allows for a streamlined process of installing PowerCLI. There have been new cmdlets added to handle the management of DRS clusters. Several modules have been updated to interact with views for the newest APIs on SRM, vR Ops, Horizon View, and vSAN. The storage module has had quite a few improvements made around the vSAN iSCSI capabilities as well as SPBM.

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

Thoughts around PowerCLI and the Powershell Gallery

I am *very* excited to share some thoughts and possibilities for PowerCLI.

Packaging and Installation are big areas we have been looking at. We have heard loud and clear that our customers wanted to embrace modules and in our recent releases we have moved away from snapins into modules. We’re now looking at how we package the modules and deliver them to our users.

One possibility would be releasing PowerCLI exclusively from the Powershell Gallery, the central repository for Powershell modules. The benefits of this would be great, as it provides easy installation and upgrade, follows Powershell patterns for modules, and most importantly would allow us to deliver PowerCLI to multiple platforms, such as Linux and MacOS.

Here is an idea of what we are currently thinking:

  1. You would need to make sure you have the latest Powershell. WMF 5.1 is required for the PowershellGet cmdlets, which includes install-module. (You may want to do this now!)
  2. Make sure $env:PSModulePath includes C:\Program Files\WindowsPowerShell\Modules . This is only precautionary because it should already be set, but you should check anyway.
  3. Prior to installation of the PowerCLI from the Microsoft Gallery you would need to uninstall any previous version of PowerCLI that was installed by MSI.
  4. You would no longer have PowerCLI shortcuts on your desktop. PowerCLI would be immediately available when you run powershell, no Import-Module required. If you really miss the icon, find me at a conference and I’ll give you a sticker! 🙂
  5. Installation of PowerCLI on machines that cannot access the Powershell Gallery can be done by saving the module to a thumb drive or network share accessible to the installation target and dropping the files in the module folder of the destination computer or using Install-Module with a path to the downloaded file.
  6. We are thinking about using Update-Module in the future to make geting the latest bits faster and easier!

I understand that change can be hard, so I’m giving you the opportunity to tell us why (or why not) a Powershell Gallery installation/update would not work for you.

Regarding the results from the survey we recently held, an extremely high percentage of the respondents prefer the Gallery installation for ease of installation and updates. Still, there were a few respondents that had some concerns that I want to address here.

  1. “The Powershell Gallery is not as secure as downloading an MSI from vmware.com” – This is not true. We digitally sign all PowerCLI files as we always have, guaranteeing authenticity. PowershellGet has built-in verification of the digital signature, and will not install unsigned modules unless you explicitly skip the publisher check.
  2. “This makes offline installation/upgrades much harder” – So far, I’ve identified two different methods of offline installation and both require less steps (and ZERO mouse clicks). Method one uses Save-Module to copy to a network drive accessible by the ‘offline’ machine. You could also save to a USB drive or any other storage location that your installation target can access. Method two uses Invoke-WebRequest to download the package and can again be saved to a location of your choosing. Either of these options are still far easier than the current process.

Conclusion

In my prior life as a customer, I could only dream of installation and upgrades being this easy. By releasing to the gallery, it would not only make *that* dream come true, but would also give us the ability to accelerate our releases to get improvements out for you to enjoy much sooner.

Added to this we would be bringing PowerCLI back in line with the PowerShell patterns and ensuring future powershell enhancements made around modules and module tooling could easily be consumed with PowerCLI.

I hope you join with me in the excitement of the amazing opportunities we have with PowerCLI!

What are you excited or concerned about with a Powershell Gallery release? Let us know in the comments here!

 

Using PowerCLI for Distributed Switch Management

We’re excited to release another video in the series on PowerCLI tips and tricks! This time we’re covering how to use PowerCLI for distributed switch management.

This video shows how to perform the following tasks easily:

  • Creating a vSphere Distributed Switch
  • Adding Hosts to the Created vSphere Distributed Switch
  • Creating Distributed Port Groups
  • Creating a VMKernel NIC with vMotion Enabled
  • Creating a VMKernel NIC with Fault Tolerance Enabled
  • Backing Up a vSphere Distributed Switch Configuration
  • Restoring a vSphere Distributed Switch Configuration

Watch the Video

Other videos in this series are available below. If you haven’t seen them yet, I highly recommend them. They are all quick, easy to learn and easy to reproduce in your own environment.