Since the change to 4.1, we've been upgrading all of our hosts from ESX 4.0 to ESXi 4.1. Until recently, I wasn't aware that vMotion was now offered with vSphere Standard licensing, and as a result, was not enabling vMotion during a PowerCLI scripted host setup. This presented me with the opportunity to 1.) Write a script to mass-enable vMotion, and 2.) pass that script along to others in the community.
$viserver = Connect-VIServer -Server vcenter.domain.com -Protocol https $vmhosts = Get-VMHost foreach ($vmhost in $vmhosts) { if ( ($vmhost.Version -eq "4.1.0") -and ($vmhost.PowerState -eq "PoweredOn") ){ $vmknic = Get-VMHostNetworkAdapter -VMHost $vmhost | where {$_.PortGroupName -like "YourPortGroupNameHere"} if ($vmknic.VMotionEnabled -eq "False") { Set-VMHostNetworkAdapter -VirtualNic $vmknic -VMotionEnabled $true -Confirm:$false } } }
I hope someone gets some use out of this. Go PowerCLI!
@sixfootdad
A little bit simpler:
From examples, enable VMotion on all VMkernels
Get-VMHost | Get-VMHostNetworkAdapter -VMKernel | Set-VMHostNetworkAdapter -VMotionEnabled $true
Or just on specific ones, based on portgroup name, like you did:
Get-VMHost | Get-VMHostNetworkAdapter | where { $_.PortGroupName -eq "VMkernel 1" } | Set-VMHostNetworkAdapter -VMotionEnabled $true
I don't see any need to check if host is 4.1.0. In 99% cases you will upgrade all hosts in cluster, so you can limit your view by taking just one cluster:
Get-Cluster Cluster4.1 | Get-VMHost |
Or just include 4.1 to where statement
Get-VMHost | where {($_.Version -eq "4.1.0") -and ($_.PowerState -eq "PoweredOn")} |
---
MCSA, MCTS Hyper-V, VCP 3/4, VMware vExpert
Anton, yes, those are simpler. I run a distributed environment, with about 50 clusters in roughly 40 datacenters -- at this time, there's still a mix of ESX 4.0 and ESXi 4.1 (but not mixed in the clusters). We also run multiple vmknics, and I only wanted to enable vMotion on vmknic that belonged to a specific portgroup. My enthusiasm for PowerCLI, and the excitement that a 5 minute script can accomplish a great deal of manual work (not to mention removes the possibility of human error) got in the way of explaining the reasons behind my script fully.
@sixfootdad