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 are Linux-based servers. Thus, it certainly helps if sysadmins understand Linux in order to manage and troubleshoot the servers. But 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.

Win the monthly 4sysops member prize for IT pros

Share
2+

Users who have LIKED this post:

  • avatar
  • avatar

Related Posts

0 Comments

Leave a reply

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

*

CONTACT US

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

Sending
© 4sysops 2006 - 2017

Log in with your credentials

or    

Forgot your details?

Create Account