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.

Dan Franciscus

Dan Franciscus is a systems engineer and VMware Certified Professional (VCP) specializing in VMware, PowerShell, and other Microsoft-based technologies. You can reach Dan at his blog or his Twitter at @dan_franciscus.

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!

2+

Users who have LIKED this post:

  • avatar
  • avatar
Share
11 Comments
  1. Gabe 1 year ago

    Good info but ESXi is not linux based 🙂

    0

  2. balaji mundhe 12 months ago

    yup , vmkernel totally linux based which manage / control esxi

    0

  3. Gabe 12 months 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: https://blogs.vmware.com/vsphere/2013/06/its-a-unix-system-i-know-this.html

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

    0

    • Michael Pietroforte 12 months ago

      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;

      0

      • Gabe 12 months 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."

        0

        • Michael Pietroforte 12 months ago

          Oh yes, I missed that. Thanks for clearing this up! 🙂

          0

        • Paolo Maffezzoli 12 months ago

          Personally I thought it was Linux based. In any case we can consider ESXi as Unix-like operating system. Also today I learned something new.

          1+

          Users who have LIKED this comment:

          • avatar
  4. Author
    Dan Franciscus 12 months ago

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

    1+

    Users who have LIKED this comment:

    • avatar
    • Gabe 12 months ago

      Awesome Dan!

      0

  5. Luc Fullenwarth 12 months ago

    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.

    https://busybox.net/about.html

    1+

    Users who have LIKED this comment:

    • avatar

Leave a reply

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

*

© 4sysops 2006 - 2019

CONTACT US

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

Sending

Log in with your credentials

or    

Forgot your details?

Create Account