Enabling vMotion on VMKernel Ports via PowerCLI

You maybe have to disable or enable vMotion traffic on some VMKernel ports on ESXi for doing some maintenance tasks. Disabling or enabling takes lot of time for many servers in datacenter. You can disable or enable vMotion via PowerCLI by run a simple script.

The below script will enable vMtion for all ESXi hosts on a vCenter:

Get-VMHost | Get-VMHostNetworkAdapter -Name (VMKernel Port Name) |Set-VMHostNetworkAdapter -VMotionEnabled $true

Note: Change “VMKernel Port Name” with specific VMKernel port on your ESXi servers. Change “$true” to “$false” for disabling vMotion.

You can find VMKernel ports for specific ESXi hosts or all the ESXi hosts with the below scripts:

Get-VMHost (Host Name or Host IP) | Get-VMHostNetworkAdapter -VMKernel

Note: Remove “Host Name or Host IP” to list all ESXi servers’ VMKernel ports.

If you want to disable or enable vMotion on ESXi hosts within cluster, you can use the below script:

$ESXi_Hosts=Get-Cluster -Name Cluster1 | Get-VMHost ForEach ($ESXi_Host in $ESXi_Hosts) { Get-VMHost $ESXi_Host | Get-VMHostNetworkAdapter -Name vmk0 |Set-VMHostNetworkAdapter -VMotionEnabled $true }

Note: Change Cluster1 with your cluster name and also if you want disabling vMotion, replace $true with $false.

More on Teimouri.Net

Java.net.SocketException: No buffer space available – VMware View Connection Server

Update VMware Tools Automatically

ESXi Command-Line – Part 1

Run ESXi Commands Via PowerShell And SSH

[Script]: Check Time Synchronization with Host on Virtual Machines – PowerCLI

[PowerCLI]: Add Local Administrator Account on ESXi

[PowerCLI]: ESXi Syslog Configuration via PowerCLI

[How To]: ESXi Installation Stopped – partedUtil Failed

[Script]: Find ESXi HBA WWN via PowerCLI