Managing VMware ESXi services with PowerCLI

To manage ESXi services, admins can leverage five cmdlets that can start, stop, get, set, and restart services. In this article, I will show how to use these PowerCLI cmdlets for managing ESXi services.

ESXi hosts run a proprietary kernel but allows SSH access that includes various Linux commands. Thus, it certainly helps if sysadmins understand Linux in order to manage and troubleshoot the servers. Fortunately, for VMware admins who are experts only in Windows, PowerCLI can be an option when it comes to many ESXi tasks.

PowerCLI service cmdlets

PowerCLI service cmdlets

Getting the status of ESXi services ^

To show the status of services on an ESXi host, we can use the Get-VMHostService cmdlet. This cmdlet has only three unique parameters: -VMHost, -Server, and -Refresh. The -Refresh parameter refreshes data on the service before printing it to the console.

In the example below, I am just showing the current service status on the ESXi host VMHost-1:

Starting, stopping and restarting ESXi services ^

In the next example, I will show how to use PowerCLI to start and stop ESXi services. First, we need to place the VMhost and service we want to manage into a variable in PowerShell.

Here, I want to start the SSH service, so I use Get-VMHostService to specify the host and service:

Now, I simply use the $VMHostService variable with Start-VMHostService to start the SSH service:

If I would like to restart the SSH service, I just specify the Restart-VMHostService cmdlet along with the same PowerShell variable:

Modifying ESXi services ^

To modify the policy on a specific service, we use Set-VMHostService. Again, we will specify the same ESXi SSH service, but instead of the default policy of not having the service running, we will enable it to be On, meaning it will start the service upon boot.

Automating bulk changes to ESXi services ^

One of the great features of PowerShell, and thus PowerCLI, is the ability to automate a time-consuming task. For instance, if we would like to set all ESXi services on all of our hosts in the cluster so the Active Directory service is On, we can do this with one line of PowerShell.

First, we connect to our vCenter from PowerCLI:

Now, we pipe the results of Get-VMHostService using a wildcard to find all VMHosts in the cluster to Set-VMHostService using -Policy On:

Within seconds, all VMHosts in the cluster have the Active Directory service running.

Join the 4sysops PowerShell group!

Your question was not answered? Ask in the forum!

  1. Gabe 2 years ago

    Good info but ESXi is not linux based 🙂


  2. balaji mundhe 2 years ago

    yup , vmkernel totally linux based which manage / control esxi


  3. Gabe 2 years ago

    I’m sorry but you’re both wrong. As of 4.1, ESXi has its own VMware developed micro kernel that’s is NOT Linux based. When you SSH into a host, you’re actually using a BusyBox shell that includes a lot of the commands you recognize from Linux.

    From VMware themselves:

    Look up FACTS before randomly saying things without knowing for SURE. It’s dangerous to live otherwise.


    • Gabe,  I actually looked this up. This Wikipedia article claims that a Linux kernel is loaded first and then comes the vmkernel:

      It includes its own kernel: A Linux kernel is started first,[10] and is then used to load a variety of specialized virtualization components, including ESX, which is otherwise known as the vmkernel component.[11] The Linux kernel is the primary virtual machine;


      • Gabe 2 years ago

        Yes, Michael, that was true for ESX, not ESXi. if you look later in that paragraph it says:
        "VMware dropped development of ESX at version 4.1, and now uses ESXi, which does not include a Linux kernel."


  4. Author

    Ive updated the post to reflect that ESXi is not linux-based.

    • Gabe 2 years ago

      Awesome Dan!


  5. BusyBox: The Swiss Army Knife of Embedded Linux
    BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.

    BusyBox has been written with size-optimization and limited resources in mind. It is also extremely modular so you can easily include or exclude commands (or features) at compile time. This makes it easy to customize your embedded systems. To create a working system, just add some device nodes in /dev, a few configuration files in /etc, and a Linux kernel.


Leave a reply

Your email address will not be published. Required fields are marked *


© 4sysops 2006 - 2020


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account