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

Tag Archives: VMware

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.

Spotlight on the Move-VM Cmdlet including PowerCLI 6.5 Enhancements

VMware PowerCLI 6.5’s release introduced a lot of new cmdlets and improvements to existing cmdlets. One of my favorite improved cmdlets has to be Move-VM. Move-VM was already a very versatile cmdlet before this new release. It could be used to move a VM between hosts, datastores, resource pools, clusters, to new folders, to a vApp, and so forth. Now, with PowerCLI 6.5 R1, Move-VM can move VMs between vCenters! We can even take that a step further, Move-VM can move VMs to vCenters which are not linked together by SSO domain. That’s something that cannot be done by the web client!

Let’s start by taking a look at the newest addition to the cmdlet, migrating VMs between vCenters.

Cross vCenter vMotion

Cross vCenter vMotion was introduced with vSphere 6.0. It’s proved to be a great feature that opens up new options in flexibly managing a vSphere environment. One of the limitations in using cross vCenter vMotion by way of the Web Client is that it can’t migrate VMs between SSO domains. This is where the usage of PowerCLI is hugely beneficial because PowerCLI allows users to fill that gap. The key to PowerCLI being able to overcome that limitation is due to its ability to connect to multiple vCenter servers at the same time.

In order to perform a cross vCenter vMotion, there are a couple parameters that are needed:

  • Active Connection to both Source and Destination vCenters
  • Source vCenter
    • VM
    • VM’s Network Adapter/s
  • Destination vCenter
    • Destination ESXi Host
    • Destination Datastore
    • Destination PortGroup/s

Here’s some example code on how that can be accomplished:

I also want to filling in a couple informative gaps in the above code:

  • Due to the cross vCenter vMotion functionality being added in as part of vSphere 6.0, it can only be performed against vCenter servers of 6.0 and newer.
  • The destination parameter only accepts an individual ESXi host. A workaround could look like the following code:
  • The datastore parameter only accepts an individual datastore. A workaround could look like the following code:

Multiple NIC VM vMotion

If you look at the example code above, specifically at the network pieces, you’ll notice that it only focuses on moving a VM with a single NIC. However, both the NetworkAdapter and PortGroup parameters accept arrays. This means that you can pass multiple objects to those parameters.

One key thing to note is that the first item in each array will be referenced together, then the second items will be referenced together, and so on and so forth. If there are multiple network adapters and only one portgroup specified, the network adapters will all be assigned to the same portgroup. If there is only a single network adapter and multiple portgroups specified, the command will error out.

Here’s an example of doing a Cross vCenter vMotion on a VM that has multiple NICs:
Move-VM with Multiple Network Adapters

Conclusion

The above examples are just the tip of showing just how versatile the Move-VM cmdlet really is. Let us know how you’re using Move-VM in your environment in the comments below!

For more information on its use in your environment, see the PowerCLI cmdlet reference on Move-VM.

New Release: PowerCLI 6.5 R1

There’s been a lot of buzz around PowerCLI lately, and we’re keeping it going! It gives me great pleasure to announce the general availability of VMware PowerCLI 6.5 Release 1!

Before diving in on all the new features, it’s worth noting that these features are all created based on feedback taken directly from the users. Please help us make the product better by letting us know what would make PowerCLI easier to use and what would make your automation tasks less painful! The PowerCLI Product Manager, Development Team and I, would like to extend a huge Thank You to the community for their great feedback and consistent drive to enhance the product.

Cmdlet Updates

The Core vSphere module has received a number of updates as well as stability and performance improvements. The most notable updates include cmdlets based around VM creation and management. The ‘Move-VM’ cmdlet now supports the ability to vMotion VMs between vCenters which is known as Cross vCenter vMotion. Performing a Cross vCenter vMotion with PowerCLI also allows the VM to traverse between separate SSO domains too! This is something not available with the GUI. The ‘New-VM cmdlet now supports configuring a VM to have a specific number of CPU cores. Then, the ‘Open-VMConsoleWindow’ has been updated to provide access to the latest and greatest version of the VMware Remote Console (VMRC). Lastly, various cmdlets have received updated views to allow access to the new vSphere 6.5 APIs!

Storage Module Updates

The PowerCLI Storage module has been a big focus on this release. A lot of functionality has been added around vSAN, VVOLs, and the handling of virtual disks. The vSAN cmdlets have been bolstered to more than a dozen cmdlets which are focused on the entire lifecycle of a vSAN cluster. The entire vSAN cluster creation process can be automated with PowerCLI as well as running tests, updating the HCL database, and much more!

  • Get-VsanClusterConfiguration
  • Get-VsanDisk
  • Get-VsanDiskGroup
  • Get-VsanFaultDomain
  • Get-VsanResyncingComponent
  • Get-VsanSpaceUsage
  • New-VsanDisk
  • New-VsanDiskGroup
  • New-VsanFaultDomain
  • Remove-VsanDisk
  • Remove-VsanDiskGroup
  • Remove-VsanFaultDomain
  • Set-VsanClusterConfiguration
  • Set-VsanFaultDomain
  • Test-VsanClusterHealth
  • Test-VsanNetworkPerformance
  • Test-VsanStoragePerformance
  • Test-VsanVMCreation
  • Update-VsanHclDatabase

vSphere 6.5 introduces a new way to handle the management of virtual disks. Instead of managing a VM’s hard disks through the VM, they can now be managed independently with new PowerCLI cmdlets. This allows the handling of a virtual disk’s lifecycle to be decoupled from the lifecycle of a VM. This adds a ton of flexibility!

  • Copy-VDisk
  • Get-VDisk
  • Move-VDisk
  • New-VDisk
  • Remove-VDisk
  • Set-VDisk

PowerCLI has been updated to include new cmdlets that allow for the automated management of the VVOL replication features which are new to vSphere 6.5. Some of the new features include finding fault domains and replication groups, syncing replication groups, as well as preparing for and starting the failover process to the target site.

  • Get-SpbmFaultDomain
  • Get-SpbmReplicationGroup
  • Get-SpbmReplicationPair
  • Start-SpbmReplicationFailover
  • Start-SpbmReplicationPrepareFailover
  • Sync-SpbmReplicationGroup

Horizon Module

A brand-new module has been included to work with VMware Horizon! This has been a long time coming and has finally been released. The module can be installed anywhere and then remotely connect to the Horizon Connection server, a huge improvement over the last offering. Speaking of improvements, the module provides access to 100% of the public API through the Connect-HVServer and Disconnect-HVServer cmdlets. Keep an eye on the PowerCLI-Examples Github repo for functions allowing you to easily work with this module and provide sample code!

Compatibility

As with all versions of PowerCLI, it’s also backwards compatible going back to vSphere 5.5!

PowerCLI and vSphere Compatibility

The Storage module is compatible with vSAN 6.0 and newer, as well as Site Recovery Manager 6.1 and newer!

PowerCLI and vSAN SRM Compatibility

Last, the Horizon module is compatible with Horizon 7.0.2.

PowerCLI and Horizon Compatibility

PowerCLI Core

As if this release wasn’t enough, PowerCLI Core also has support for the new 6.5 vSphere APIs! This ensures those core vSphere cmdlets and Views are available to other operating systems PowerCLI Core operates on as well!

More Information and Download

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

You can find the PowerCLI 6.5 Release 1 download HERE. Get it today!

Free PowerCLI Training (or a test lab) now available

You still haven’t learned PowerCLI?  What are you waiting for?

Now, you have no excuse, recently we split out the PowerCLI content into its own lab to allow you to get started with PowerCLI for FREE!

The PowerCLI lab contains a step by step course on PowerCLI enabling you to go from a beginner all the way to an expert, its a handy way to learn in the safe knowledge that you will not harm anything in your environment.

It also makes for a great test lab for testing your scripts, did you know you can paste your code into the environment, here is how:

SendScripts

Learn more from the PM in this quick video

Where do I go to get started?

You can take the lab by visiting http://vmware.com/go/PowerCLILab

New release: PowerCLI 6.3 R1–Download it today!

It is my pleasure to inform you that vSphere PowerCLI 6.3 Release 1 has now been released and as usual we have some great features to ensure you are able to automate even more features and in this release, faster than ever!  As always we take feature requests directly from customers, through feedback at conferences, by looking at the communities and multiple other ways. please do keep giving us your feedback to enable us to keep making the product easier and making automation tasks less painful.

PowerCLI 6.3 R1 introduces the following new features and improvements:

 

Get-VM is now faster than ever!

imageThe Get-VM Cmdlet has been optimized and refactored to ensure maximum speed when returning larger numbers of virtual machine information. This was a request which we heard time and time again, when you start working in larger environments with thousands of VMs the most used cmdlet is Get-VM so making this faster means this will increase the speed of reporting and automation for all scripts using Get-VM. Stay tuned for a future post where we will be showing some figures from our test environment but believe me, its fast!

 

New-ContentLibrary access

imageNew in this release we have introduced a new cmdlet for working with Content Library items, the Get-ContentLibraryItem cmdlet will list all content library items from all content libraries available to the connection. This will give you details and set you up for deploying in our next new feature….

The New-VM Cmdlet has been updated to allow for the deployment of items located in a Content Library. Use the new –ContentLibrary parameter with a content library item to deploy these from local and subscribed library items, a quick sample of this can be seen below:

$CLItem = Get-ContentLibraryItem TTYLinux
New-VM -Name “NewCLItem” -ContentLibraryItem $CLItem -Datastore datastore1 -VMHost 10.160.74.38

Or even simpler….

Get-ContentLibraryItem -Name TTYLinux | New-VM -Datastore datastore1 -VMHost 10.160.74.38

 

ESXCLI is now easier to use

Another great feature which has been added has again come from our community and users who have told us what is hard about our current version, the Get-Esxcli cmdlet has now been updated with a –V2 parameter which supports specifying method arguments by name.

The original Get-ESXCLI cmdlet (without -v2) passes arguments by position and can cause scripts to not work when working with multiple ESXi versions or using scripts written against specific ESXi versions.

A simple example of using the previous version is as follows:

$esxcli = Get-ESXCLI -VMHost (Get-VMhost | Select -first 1)

$esxcli.network.diag.ping(2,$null,$null,“10.0.0.8”,$null,$null,$null,$null,$null,$null,$null,$null,$null)

Notice all the $nulls ?  Now check out the V2 version:

$esxcli2 = Get-ESXCLI -VMHost (Get-VMhost | Select -first 1) -V2

$arguments = $esxcli2.network.diag.ping.CreateArgs()

$arguments.count = 2

$arguments.host = “10.0.0.8”

$esxcli2.network.diag.ping.Invoke($arguments)

 

Get-View, better than ever

imageFor the more advanced users out there, those who constantly use the Get-View Cmdlet you will be pleased to know that a small but handy change has been made to the cmldet to enable it to auto-complete all available view objects in the Get-View –ViewType parameter, this will ease in the use of this cmdlet and enable even faster creation of scripts using this cmdlet.

 

Updated Support

As well as the great enhancements to the product listed above we have also updated the product to make sure it has now been fully tested and works with  Windows 10 and PowerShell v5, this enables the latest versions and features of PowerShell to be used with PowerCLI.

PowerCLI has also been updated to now support vCloud Director 8.0 and vRealize Operations Manager 6.2 ensuring you can also work with the latest VMware products.

 

More Information and Download

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

You can find the PowerCLI 6.3 Release 1 download HERE. Get it today!

EVC with PowerCLI 5.5 R2–Part 2

In this previous post we talked about one of the great new features introduced in PowerCLI 5.5 R2 for configuring EVC, in this post we will continue to show how we can make configuring and using EVC easier with PowerCLI.

Compatibility checks

While configuring EVC on a cluster you will probably need to perform some compatibility checks. Here’s how you can automate them with a script.

Check host’s compatibility with a target EVC mode

Continue reading

New Release: vSphere PowerCLI 5.5 R2

image

I am pleased to announce that vSphere PowerCLI 5.5 R2 has now been released and has some great new features.  In this release we take PowerCLI one step further and allow even more troubleshooting, reporting and automation of vCloud Suite products by introducing easy access to vCenter Site Recovery Manager (SRM) APIs through the core PowerCLI cmdlets.

 

Why wait, download the latest version today from here.

vSphere PowerCLI 5.5 Release 2 introduces the following new features and improvements, for a full list of all that has changed please check the full vSphere PowerCLI 5.5 R2 Release notes here.

Full management of the vCenter SRM Public API

Using the Connect-SRMServer and Disconnect-SRMServer you are now able to connect to vCenter SRM and access
all public APIs available, use of the $global:DefaultSrmServers object properties and methods after connection allow for access to recovery group and protection group automation, see the built in help and examples for more information and watch out for future posts with more information on this site.

Support for creating and removing Tags and Tag Categories

Enhancing the cmdlets from the previous version of PowerCLI we are now able to use PowerCLI for complete Tag management with the added New/Set/Remove Tag and TagCategory cmdlets.

Enable/Retrieve information on EVC Mode for Clusters

Adjustments to the Host and Cluster Cmdlets now allow for enabling, disabling and retrieving information for EVC Mode making automated build environments one step easier to accomplish.

Security policies for vSphere standard switch and port groups

Security policies can now be easily adjusted on vSphere standard switches and portgoups using the Get/Set-SecurityPolicy cmdelts.

Added support for PowerShell 4.0

PowerCLI can now be installed and used with the latest version of PowerShell at this time, PowerShell 4.0

Added support for IPv6

PowerCLI has now been updated to support vSphere servers configured with IPv6

Added statistical information

PowerCLI has been updated and we have added the ability to specify all supported types including clusters, datastores, etc and retrieve more statistical information via the Get-Stat and Get-StatType cmdlets.

64 bit Support

The New/Set-OSCustomizationSpec cmdlets have been updated to work in 64-bit PowerShell and no longer require running in a 32-bit PowerShell environment.

Even more updates

The above list is a high level list of the updates made to vSphere PowerCLI, for a more comprehensive list including all parameter and functional improvements, security enhancements, and deprecated features, see the vSphere PowerCLI Release Notes and the vSphere PowerCLI Change Log.

For more information on specific product features, see the VMware vSphere PowerCLI 5.5 Release 2 User’s Guide.

For more information on specific cmdlets, see the VMware vSphere PowerCLI 5.5 Release 2 Cmdlet Reference.

Download and Install PowerCLI 5.5 Release 2 today from here.

New Book: Learning PowerCLI

Everyone I meet sees the time that PowerCLI can save you by automating your day to day tasks, easily creating reports, troubleshooting your environment and much more but to use PowerCLI you first need to take the time to learn it, this can be achieved in a variety of methods but still the most popular is reading a book and putting it into practice.

If you are the reading kind of person then make sure you check out the existing PowerCLI Library of books:

 

Learning PowerCLI

There is a new book now available with the latest up to date information, it was written specifically with the vSphere Admin in mind and shows how you can easily get started using PowerCLI.  The book was written by community member Robert van den Nieuwendijk and published by PACKT.

The book is available in all good book stores and online book retailers such as with Amazon here.  Whats more you can take a look inside the book to see if its for you here.

What you will learn from this book

    • Download and install PowerCLI
    • Add hosts to VMware vCenter Server
    • Configure vSphere Auto Deploy
    • Use the esxcli command from PowerCLI
    • Create OS Customization Specs
    • Monitor virtual machine performance
    • Configure distributed virtual switches and storage I/O Control
    • Enable VM and Application Monitoring
    • Manage licenses for multiple hosts to migrate them easily
    • Configure an alarm to monitor your networks virtual machines
    • Generate a good-looking HTML report in no time

Win a copy

PACKT and Robert were kind enough to give VMware 5 copies of the book to give away here, in order to win a copy all you need to do is add a comment to this site (make sure you include your email address) telling us why you need to learn PowerCLI.

Entries will be judged by Robert and chosen by March 14th 2014, once chosen you will receive an email with a link to receive your copy of the book.

Good Luck.

Introduction to PowerCLI

Here at VMware we still get questions from people who are starting out with PowerCLI,

To make sure everyone is aware of the power that is available to system administrators in PowerCLI we wanted to create the below introduction which answers some of the frequent questions we receive when people start out on their journey to manage VMware platforms with the command line interface and provide automation to the Software Defined Data Center.

Using Tags with PowerCLI

The Tagging feature was introduced in vCenter Server 5.1 where custom defined tags can be categorized and added to any of your inventory objects in your environment.

Tags can be quickly searched on and retrieved quickly. Multiple unique tags can be used on the same inventory object creating granular metadata that can easily be grouped and search on.

As an example this is helpful for looking for all VMs tagged against a particular project or placing all departmental objects into groups, IE HR requiring not just there VMs but networking and datastores used as well, This all benefits the administrator by simplifying management and making information more easily available.

 

Continue reading