The VMware PowerCLI 12.2 is released now. It brings plenty of improvements to the existing cmdlets and introduces new cmdlets.
Please find the release highlights here-
- Horizon
- VMware Horizon PowerCLI module is now supported for macOS and the Linux OS
- VMC
- We’ve added support for one of the most popular VMware Cloud Services – DRaaS. Using the new cmdlets customers can now enable/disable DRaaS on their VMC SDDC as well as add and remove SRM instances.
- vSphere
- Extended support for vLCM
- New cmdlets to export and import the cluster desired state
- New cmdlets to get the vLCM recommendations
- New cmdlets to get the vLCM hardware compatibility
- Enhanced Set-Cluster to allow custom depot for ROBO environments
- Extended the support ‘ovf’ parameters for the content library item
- Added support for VM templates in the content library
- Foreach-object -Parallel is now supported
- Extended support for vLCM
- Workload Management
- New cmdlets to manage namespace limits
- NSX-T
- NSX-T global manager APIs are now supported
In this blog post, I will discuss some of these improvements in detail.
VMware Horizon – Compatible with macOS and Linux
There was a requirement for a long time to make VMware Horizon compatible with PowerShell core. The good news is, it is now compatible with PowerShell core to work with macOS, Linux, or any other platform of your choice.
‘DRaaS’ Support for VMC
New cmdlets have been introduced to support the DRaaS management. The new cmdlets allow you to activate ‘Site recovery’ on a specified SDDC and help you manage Site recovery instances.
Activate Site Recovery on an SDDC
The Set-VmcSddc has got a new parameter called -EnableSiteRecovery, which allows you to activate site recovery on a specific SDDC. Check out below PowerCLI snippet and a short demo.
1 2 |
$sddc = Get-VmcSddc -name ‘test_zerocloud_sddc’ Set-vmcSddc -SDDC $sddc -EnableSiteRecovery |
Check out the Set-VmcSddc cmdlet reference to know more.
Manage Site recovery Instances
A new set of cmdlets are introduced to manage the Site recovery instances. Once site recovery is enabled, you can manage the instances via the below cmdlets.
Get-VmcSddcSiteRecoveryInstance
New-VmcSddcSiteRecoveryInstance
Remove-VmcSddcSiteRecoveryInstance
Extended Support for vLCM
We have introduced the vSphere Lifecycle Manager (vLCM) cmdlets starting from PowerCLI 12.1. With the release of PowerCLI 12.2, we are now further extending the vLCM cmdlet coverage. Let’s look at some of these operations in detail.
Export Cluster Desired state
A new cmdlet Export-LCMClusterDesiredState is introduced to export a cluster desired state. Do check out the cmdlet reference to learn more.
Ex.
1 |
Get-Cluster -name ‘Cluster’ | Export-LCMDesiredState -Destination \documents\ClusterdesiredState -ExportIsoImage -ExportOfflinebundle |
Import Cluster Desired Image
A new cmdlet Import-LCMClusterDesiredState is introduced to import a cluster desired state. Do check out the cmdlet reference to learn more.
Ex.
1 |
Import-LCMDesiredState -Cluster ‘vLCM-Cluster’ -LocalSpecLocation \Documents\ClusterdesiredState\cluster-desired-state.json |
Get vLCM Recommendations
A new cmdlet is introduced to provide the desired state recommendation if any new base image is available to use.
Check out the details here.
Get-LcmClusterDesiredStateRecommendation
Override custom depot
We have added an additional parameter –DepotOverrides <String[]> to the Set-Cluster cmdlet, which allows you to define a custom image depot to be used by vLCM.
1 |
Set-Cluster -DepotOverrides <String[]> |
Extended PowerCLI support for content library items
Please find the details of enhancements we are introducing with PowerCLI 12.2 concerning the content library item.
OVF Parameters on a Content Library Item
A new parameter -ContentLibraryItem is added on Get-OvfConfiguration cmdlet. It will allow you to fetch and update the ovf parameters from a content library item.
Example:
1 2 3 4 5 6 7 8 9 10 |
$ContentLibItem Get-ContentLibraryItem -name 'ContentLibraryItem' $vmhost = get-VMHost -name '10.23.81.190' $ovfConfig = get-OvfConfiguration -ContentLibraryItem $ContentLibItem -Target $vmhost $ovfConfig $ovfConfig.EULAs.Accept.Value=$true $ovfConfig.NetworkMapping.Network_1.Value= 'VM Network' |
Specify OvfConfiguration
New OVFConfiguration parameter has been added to the New-VM cmdlet to allow specifying OVF parameters when deploying OVF template from the content library
1 2 3 |
New-VM -name 'MyVM' -VMHost $vmhost -ContentLibraryItem $ContentLibItem -OvfConfiguration $ovfConfig $vm = Get-VM -name 'MyVM' $vm| Format-List |
Deploy VMs from VM Templates Stored in a Content Library
New-VM cmdlet is now capable of deploying VMs from VM templates in a content library
1 2 |
New-VM -Name 'MyVMFromtemplate' -VMHost -ContentLibraryItem $vmTemplateContentLibItem Get-VM -name 'MyVMFromTemplate' |
Foreach-Object -parallel {} is now supported
PowerShell team introduced a new switch -Parallel to foreach-object cmdlet starting from PowerShell v7. The new switch allowed PowerShell to execute parallel jobs on a collection of objects, thus reducing overall execution time. However, Foreach-Object -parallel wasn’t supported with VMware PowerCLI until now.
When you use Foreach-Object -parallel, PowerShell creates child runspaces to execute the respective jobs. The problem PowerCLI had was that it couldn’t reuse the VISessions within the child runspace hence failing to execute the PowerCLI cmdlets.
Happy to inform you all that foreach-object -Parallel is now supported with PowerCLI. This can be achieved by 2 ways.
Inline -Server parameter
You will require to store VISession in a variable and pass the connection variable to each PowerCLI cmdlet under foreach-object -parallel.
Let’s take a look at the below example.
1 2 3 4 5 6 7 8 9 |
$cred= Get-Credential $conn = Connect-VIServer testvcsa.cpbu.com -Credential $cred Function Execute-WithoutPcliContext { $vmlist= get-VM $vmlist |ForEach-Object -Parallel { (Get-VM -Name $_.Name -Server $using:conn).Name } } |
Use PowerCLI Context
You can execute and store the Get-PowerCLIContext cmdlet to a variable, which will store the VISession variables and Imported modules from the parent runspace. You can then use the PowerCLI context within the foreach-object -parallel to pass the VISession information to child run space. This method eliminates the need to specify inline -Server parameter to each PowerCLI cmdlet.
Let’s take a look at the below example.
1 2 3 4 5 6 7 8 9 10 11 |
$cred= Get-Credential $conn = Connect-VIServer testvcsa.cpbu.com -Credential $cred Function Execute-WithPcliContext { $pcliContext= Get-PowerCLIContext $vmlist= get-VM $vmlist |ForEach-Object -Parallel { Use-PowerCLIContext -PowerCLIContext $using:pcliContext -SkipImportModuleChecks (Get-VM -Name $_.Name ).Name } } |
Manage Namespace Limits via PowerCLI
Two new cmdlets have been introduced to manage the workload cluster namespace limits.
Check out below cmdlets references to know more.
Get-WMNamespaceLimits
Set-WMNamespaceLimits
Concluding this, I recommend you to visit the PowerCLI 12.2 release notes to know more about improvements and bugfixes. Also, Do check out the PowerCLI home page for anything and everything related to PowerCLI.