We are running ESX 4.0 on HP DL380G6 servers. I created a cluster with three hosts and enabled HA and DRS. I can use the VSphere GUI to tell a host to enter Maintenance Mode, and since it is in a DRS enabled cluster, it will migrate it's VMs to the other hosts in the cluster and all is well. When I try to do the same thing using PowerCLI (i.e. : Set-VMHost -VM . The host will go into maintenance mode once all virtual machines are powered off.". After which, the VMs never migrate. We are trying to create some Security Updates scripts and would like the capability to do this without having to specify the migration of each VM manually by name.
Any ideas?
If you have the DRS Automation Level set to "fully automated", all the guests should be vMotioned to the other host(s) in the cluster.
Independent if you set the ESX host to maintenance mode from the vSphere client or with PowerCLI
$esxName = "MyHostName" Get-VMHost -Name $esxName | Set-VMHost -State Maintenance
Just tried it on my test system and it worked both times.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Unfortunately, it doesn't work for us... I verified that the cluster is set to fully automated. It will migrate the hosts using the GUI, but it won't using the CLI...
You use the same account for the Gui and for the script (Connect-VIServer) ?
Anything in the vpxd logs ? Perhaps switch logging to verbose while you run the script.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, same Domain account with Admin privileges. I am using ESX 4.0 Update 1. Although it didn't work before the update either...
Could you please try to do: Set-VmHost -State "Maintenance" -Evacuate
From the cmdlet help: If the value is $true, vCenter automatically reregisters the virtual machines that are compatible for reregistration. If they are not compatible, they remain on the host. If there are powered on virtual machines that cannot be reregistered the operation waits until they are powered off manually. The -Evacuate parameter is valid only when connected to a vCenter Server system and the -State parameter is set to Maintenance. Also, the virtual machine host must be in a DRS-enabled cluster.
Luc is this working for you even if you dont's specify -Evacuate ?
10x,
Yavor
Yavor, yes this is working for me.
I think there was a similar problem in Virtual Center 2.5 Update 2.
That was solved in Update 3. See KB Article: 1007156.
I'm not aware a similar problem exists in vSphere 4 Update 1
There could also be a problem with the exposure of the Nx flag but then the Maintenance Mode should not work from the GUI either.
I suspect a "verbose" vpxd log could perhaps show the cause of the problem.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yavor, perhaps also worth checking.
At one point I had a 2-host cluster where vMotion worked in one direction but not in the other.
vMotion came with the Nx flag message.
This was a vCenter 4 cluster without EVC enabled (due to older CPU types).
In the end the problem was solved when I rebooted the ESX server from where there were no vMotions possible.
Without EVC it's not obvious to change the ESX server's CPU mask.
A reboot, afaik, will reset the CPU mask.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi hangsloose,
Could you please verify that you are using the latest PowerCLI build 4.0u1, build number 208462. You can do that by running Get-PowerCLIVersion (or if you are using an old version it would be Get-VitoolkitVersion)
Thanks,
Yavor
Yavor,
That was it! I was at v4.0.0, build 162509. It works now.
Thank you very much!
Ken "Hangsloose" Ellis
Hello,
I'm running ESX Server 3.5 U4, can I run the latest version of the VI Toolkit?
Here is what I'm running now:
VMware VI Toolkit for Windows 1.5 build 142961
Because I'm trying to put a host into Maintenance mode and move the vm's running on it to other hosts.
Here is the error that I'm getting: Using this command.
Get-VMHost -Name dodpbsv01.dodmerb.ad | Set-VMHost -State maintenance -Evacuate
Error
Set-VMHost : A parameter cannot be found that matches parameter name 'Evacuate'
.
At line:1 char:80
+ Get-VMHost -Name esxhost1 | Set-VMHost -State maintenance -Evacuate
te <<<<
+ CategoryInfo : InvalidArgument: (
, ParameterBind
ingException
+ FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.VimA
utomation.Commands.SetVMHost
Thanks,
Mike
Afaik, you have to upgrade to PowerCLU 4u1 to get the -Evacuate parameter.
This PowerCLI also supports your ESX 3.5u4 environment. See the Release Notes.
Note that for the -Evacuate parameter there are some prereqs:
*) vCenter
*) State must be Maintenance
*) guests must be in a DRS-enabled cluster
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello LucD,
So I installed the latest version 4.0.1 Update 1, do you recommend that on any new install that I just install the 4.0.1 Update 1 and skip the VI Toolkit 1.5 installation, or do you recommend that I first install the VI Toolkit 1.5, then install the 4.0.1 Update 1?
One more question: here is my powershell command for placing a host into Maintenance mode and Evacuating Vm's.
Get-VMHost -Name esx1.local | Set-VM Host -State maintenance -Evacuate
Here is the error message that I get:
C:\> Get-VMHost -Name esx1.local | Set-VM Host -State maintenance -Evacuate
Set-VM : A parameter cannot be found that matches parameter name 'State'.
At line:1 char:59
+ Get-VMHost -Name esx1.local | Set-VM Host -State <<<< maintenance -Evacuate
+ CategoryInfo : InvalidArgument: (
, ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.Commands.SetVM
Thanks, Mike
I think you have a blank between Set-VM and Host.
It should be
Get-VMHost -Name esx1.local | Set-VMHost -State maintenance -Evacuate
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
