[Script]: Enable/Disable vMotion on VMKernel Ports via PowerCLI
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
4,156 total views, 2 views today