powercli is a VMware -developed command line management VSphere implementation based on Microsoft (MSFT) PowerShell , Therefore, in the bulk operation of the CLI will alleviate many of the tedious repetitive work in the GUI environment.
Existing scenarios have a large number of physical hosts already installed ESXi, and can be managed by VCenter , because the default is to manage the Manage Management network card is not turned on VMotion , so we need to borrow this Manage Management Network card to turn on the vMotion function, in order to realize the HA function within the cluster.
Description: In general,VMware recommends that the condition allows each network card function preferably independent and separate, there is a dedicated network card to run ISCSI , there is a business network specifically set up business card, there is dedicated to node management Manage NIC, which has a network adapter specifically designed to implement ha and migrate vMotion that are highly available.
With official documentation, it's easy to find the command-line way to open vMotion (link:https://www.vmware.com/support/developer/PowerCLI/ Powercli41u1/html/set-vmhostnetworkadapter.html ):
Get-vmhost Host | Get-vmhostnetworkadapter-vmkernel | Set-vmhostnetworkadapter-vmotionenabled $true
This command enables the vMotion of network cards with VMkernel on all host hosts Get-vmhost to.
The existing scenario needs to operate on a specific HOST , so we need to change the statement:
Connect-viserver–server 172.5.140.201
Get-vmhost -name 172.5.140.160 | Get-vmhostnetworkadapter-vmkernel | Set-vmhostnetworkadapter-vmotionenabled $true
This combination is implemented by logging into a vCenter server 172.5.140.201 , and the 172.5.140.160 hosts within that jurisdiction are individually vMotion The Open
There are a lot of new hosts in this scenario that need to do this, so we need to prepare a list of these host IP files I named "hosts.txt" files, so we made some changes to the statements:
Connect-viserver–server 172.5.140.201
get-content hosts.txt | Foreach-object {get-vmhost-name $_ | Get-vmhostnetworkadapter-vmkernel | Set-vmhostnetworkadapter-vmotionenabled $true}
After logging into VCenter , the combination searches for matches in this hosts.txt line by row, and automatically fills in the foreach-object of PowerShell . $_"key information, complete batch automation open vMotion
Figure 1 A dialogue session that requires further confirmation
This output we will have a number of confirmation, such as VCenter SSL Information warning content display,VMKernel Multiple confirmation, here all need to press the more times the carriage return to complete.
So we want to make the screen output more concise and make the following changes to the statement:
Connect-viserver–server 172.5.140.201-warningaction 0
Get-content Hosts.txt | Foreach-object {Get-vmhost-name $_ | Get-vmhostnetworkadapter-vmkernel -name vmk0 | Set-vmhostnetworkadapter-vmotionenabled $true -confirm: $false}
This combination implements the Ignore SSL warning content, only vMotionon vmk0 , and ignores the confirmation that the return result is more refreshing.
Note: It is important to note that if your configuration environment does not turn on vMotion on vmk0 , use get-vmhostnetworkadapter-vmkernel command to obtain the VMKernel information on all ESXi hosts in the currently connected VCenter .
-=eob=-
Configure the vmotion capabilities of specified hosts within a cluster via VMware's POWERCLI