VMware Cloud Community
ysiguchi
Contributor
Contributor

About vCenter 6.7 command operations

Is there a way to connect to the vCenter via SSH and put the ESXi host server into maintenance mode using a command?

Reply
0 Kudos
4 Replies
larstr
Champion
Champion

ysiguchi,

Are you required to do it from vCenter? You could just install vSphere CLI - VMware {code} somewhere, but I don't think vCenter would be my first choice.

Lars

Reply
0 Kudos
Alex_Romeo
Leadership
Leadership

Hi,

Place a Host in Maintenance Mode

  • Place the host in maintenance mode.

    vicfg-hostops --server=server_name --operation enter

  • Verify that the host is in maintenance mode.

    vicfg-hostops --server=server_name --operation info

Enter Maintenance mode:

vicfg-hostops --server server_name --username user_name --password pass_word --operation enter

Exit Maintenance mode:

vicfg-hostops --server server_name --username user_name --password pass_word --operation exit

-----------------------------------

https://www.vladan.fr/esxi-maintenance-mode/

ESXi Maintenance Mode Via CLI How-to And Some More Commands

How to put a host into maintenance mode?

To enter maintenance mode using the command line interface, use this command:

*********************************************************************

esxcli system maintenanceMode set –enable true

To exit maintenance mode use this command:

esxcli system maintenanceMode set –enable false

Alternatively, there is another command to enter and to exit maintenance mode:

To enter maintenance mode:

vim-cmd /hostsvc/maintenance_mode_enter

To exit maintenance mode:

vimsh -n -e /hostsvc/maintenance_mode_exit

Blog: https://www.aleadmin.it/
Reply
0 Kudos
larstr
Champion
Champion

AlessandroRomeo68,

vicfg-hostops and vim-cmd are not available on vCenter 6.7, but should work fine on earlier releases.

Lars

Reply
0 Kudos
Alex_Romeo
Leadership
Leadership

...another solution to the answer above (It is much better)

https://www.vmwareblog.org/closed-maintenance-things-know-maintenance-mode/

  • You can do just the same procedure from a vCenter instance with PowerCLI. Here are some commands:
  • Connect-VIServer “My vCenter IP” -user “user@domain” -password “password” enables to connect to a vCenter Server instance.
  • Get-VMHost -name “My ESXi host IP” informs about the current host state.
  • Set-VMHost -VMHost “My ESXi host IP” -State “Maintenance” -RunAsync set the host into maintenance mode.
  • Set-VMHost -VMHost “My ESXi host IP” -State “Connected” –RunAsync brings the host to the normal state.
  • Disconnect-VIServer 172.16.10.5 -confirm:$false disconnects you from the vCenter Server instance.

ARomeo

Blog: https://www.aleadmin.it/
Reply
0 Kudos