Restart Management Agents on All ESX hosts in a cluster using Power CLI

Hi Guys

Can anyone advise me how to Restart the Management Agents on All ESX hosts in a cluster using PowerCli or Putty?

This is what needs to happen:

To restart the management agents on an ESX host:

Log in to your ESX host as root from either an SSH session or directly from the console.
Run this command:

service mgmt-vmware restart

Press Enter.
Run this command:

service vmware-vpxa restart

Press Enter.
Type logout and press Enter to disconnect from the ESX host.

If someone could help that would be amazing as i have about 100 hosts to restart the agents on.

Thanks
Mark
MarkAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
You need to restart agents all at the same time, I would not recommend this approach.

I would recommend, restarting the agents on a single host, and then waiting.

You can use "plink" from here

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

and send an ssh command from windows, such as

plink <hostname> service vmware-vpxa restart

and it will run the command etc

Is this 100 ESX or ESXi hosts ?
0
MarkAuthor Commented:
Hi Andrew

Thanks for this it is 100 ESX hosts, we have another 100 at another site for resilience, thats why im not too fussed about doing them all at once.

plink is ok, but looking for a PowerCli command to do them all in a loop.

Any ideas?

M
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
I asked whether you have ESXi or ESX, because later in Powershell of vSphere CLI, you can send shell commands via esxcli, and this can be done via Powershell or vSphere CLI, but esxcli is a new function which only exists in ESXi

esxcli -s hostname -u username -p password shell cmd -c "command1" [-c "command2" ...]

I think you will need to use plink, if you have ESX., which if you have ESX is now out of support, and very old. But if it works for you fine, we still have ESX 2.54 in Production.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

MarkAuthor Commented:
Sorry they are ESXi 6.0 hosts.
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
So you can apply the above esxcli statement.
0
MarkAuthor Commented:
Is there a way to loop this and run on all hosts?

I used this to enable SSH on all of them

Get-Cluster | Get-VMHost | ForEach {Start-VMHostService -HostService ($_ | Get-VMHostService | Where {$_.Key -eq “TSM-SSH”})}

Could this be changed to restart the management agents also?

M
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
to do this in powershell, you would need to install an agent/vib on all your hosts first, which probably defeats the object!

see the reference here

http://www.yellow-bricks.com/2013/01/08/automating-esxi-host-level-changes-without-opening-ssh/
0
MarkAuthor Commented:
Andrew thanks for help.

I have paid to have this scripted for us.

Thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Please post here, for the benefit of other Experts and EE Members.
0
MarkAuthor Commented:
Paid to have Custom Script created
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VMware

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.