Home > Blogs > VMware PowerCLI Blog

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.

vSphere API Access Comparison – Lightboard Style

A question keeps coming up more and more often around accessing the vSphere API with PowerCLI. The conversation is normally centered around when to use Get-View versus when referencing an object’s ExtensionData property should be used.

This provided a great opportunity to create a lightboard video to highlight the different methods:

To answer the actual question though, the choice is yours. You get access to the same information available by the vSphere API either way!

New Release: Learning PowerCLI – Second Edition Book

Learning PowerCLI - Second EditionRecently, the new book Learning PowerCLI – Second Edition was published by Packt Publishing. Learning PowerCLI – Second Edition contains 517 pages of PowerCLI goodness. The book starts with downloading and installing PowerCLI. It continues with basic PowerCLI concepts, and working with PowerShell objects. Managing vSphere host, virtual machines, virtual networks, storage, high availability, clusters, and vCenter Server are the following topics. After patching ESXi hosts and upgrading virtual machines using vSphere Update Manager, managing VMware vCloud Director and vCloud Air, using Site Recovery Manager, vRealize Operations Manager, and REST API to manage NSX and vRealize Automation, the book finishes with a chapter about reporting.

If you are new to PowerCLI or have some PowerCLI experience and want to improve your PowerCLI skills, Learning PowerCLI – Second Edition will teach you to use PowerCLI to automate your work!

What’s New

Compared to the first edition, the following new topics are added in Learning PowerCLI – Second Edition:

  • Importing OVF or OVA packages
  • Using Tags
  • Using VMware vSAN
  • Using vSphere storage policy-based management
  • Configuring enhanced vMotion compatibility (EVC) mode
  • Patching ESXi hosts and upgrading virtual machines
  • Managing VMware vCloud Director and vCloud Air
  • Using Site Recovery Manager
  • Using vRealize Operations Manager
  • Using REST API to manage NSX and vRealize Automation

Learning PowerCLI – Second Edition is available exclusively from Packt Publishing: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

About the Author

Learning PowerCLI – Second Edition is written by Robert van den Nieuwendijk. Robert is a freelance system engineer living and working in the Netherlands. He is a VMware vExpert since 2012 and a moderator of the VMware VMTN Communities. Robert has a blog at http://rvdnieuwendijk.com. You can follow Robert on Twitter as @rvdnieuwendijk.

Getting Started with PowerCLI for Horizon View

PowerCLI 6.5 introduced a brand new, completely re-written, module for Horizon View that is leaps and bounds better than the prior release. As an automation fanatic and former View administrator, PowerCLI’s offering for Horizon View has always been an important part of my toolbox.

Graeme Gordon, a Senior EUC Architect on our EUC Technical Marketing team, has created a terrific video on how to get started using this new module that we recommend checking out.

Watch the Video

Also, here’s a direct link to the blog post Graeme references in the video: Getting Started with PowerCLI 6.5 for Horizon View

New Release: PowerCLI 6.5 R1 Poster!

PowerCLI 6.5 was a big release for us. We changed the name to reflect that we’re doing a bit more than just vSphere these days, we fully converted our snap-ins to modules, and so many more upgrades and updates. There are always a lot of asks for it with every release, so I am extremely happy to finally announce the release of the VMware PowerCLI 6.5 R1 poster!

The poster features a bit of a new layout, but still features all of our cmdlets and some associated examples. It also calls out the PowerCLI Community Repository, along with some of what it contains thanks to our amazing community members, and some of the PowerCLI focused flings!

PowerCLI Poster

VMware PowerCLI 6.5 R1 Poster

If you’re looking to print one out, they are best at 39 inches width by 19 inches height.

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

Help Shape PowerCLI’s Future – Poll

Community feedback has always played an important role in how PowerCLI has evolved and improved. Whether it’s the desire to convert from snapins to modules, adding additional functionalities to existing cmdlets, or creating brand new cmdlets and modules, the feedback we receive has always been extremely important.

This time we have an ask to help shape the future of PowerCLI’s packaging, installation, and upgrade process in the form of an online poll available here: https://www.surveymonkey.com/r/HGQDJFQ

Giving a little context around the poll, there have been a lot of asks around getting PowerCLI into the PowerShell Gallery. The PowerShell Gallery is an online repository containing an amazing amount of PowerShell modules and scripts. The PowerShell Gallery allows users the ability to search, install, update, and uninstall these resources directly from a PowerShell session.

Taking a look at how we distribute PowerCLI today, this move would have some major impacts. Instead of logging into my.vmware.com then downloading and installing PowerCLI through an MSI, users could simply open PowerShell and run:

Install-Module -Name PowerCLI

Updating would change as well, as users could then run:

Update-Module -Name PowerCLI

With the changes in these installation methods, it would also mean the start menu and desktop shortcuts would no longer be automatically created at time of install.

Last big impact would be to offline installations. Since the PowerShell Gallery is an online repository, users would have to access the gallery using a system that has internet access, running a command that looks something like the following, and then completing the install by copying the module over to the offline system where it can now be imported:

Save-Module -LiteralPath "C:\MyLocalModules\" -Name PowerCLI

The last question is optional and is asking for an email address since we’ll have some goodies available as giveaways!

If you’d like some additional information about the PowerShell Gallery, see the following link: https://msdn.microsoft.com/en-us/powershell/gallery/psgallery/psgallery_gettingstarted

Here’s a link to the survey: https://www.surveymonkey.com/r/HGQDJFQ

Again, thanks to everyone for helping make PowerCLI awesome!

Welcoming a New Member to the Team

Jeffrey Snover and Jake Robinson

Jake Robinson (right) with PowerShell “father”, Jeffrey Snover (left)

I’d like to welcome someone new to the PowerCLI team: Jake Robinson.

Jake is our new Senior Product Manager for Automation Frameworks and CLIs. This means he’s going to be spending a lot of time focusing on the future of PowerCLI!

Jake has been long been a PowerCLI user. He’s even presented PowerCLI sessions at VMware and PowerShell User Groups as well as vBrownBag.

In his spare time, Jake enjoys brewing beer, playing video games, and grooming his epic beard.

When asked about the future of PowerCLI, Jake said: We are in the Post-GUI era, and PowerCLI has been, and will continue to be, the best user interface for VMware products, not just vSphere!

I think it’s fair to say the future of PowerCLI is bright!

You can find Jake’s personal blog at http://geekafterfive.com/ and contact him on Twitter via @jakerobinson