VMware Cloud Community
CG21
Enthusiast
Enthusiast

plan a task to restart a service like on all esx in vcenter

Hi,

i think th title is preaty clear. We have a vcenter versin 6.7 with host on esxi server 6.7.0.

i would like to plan a task to restart a service like ntp on all esx in this vcenter, i thnik yhere is 2 solutions :

- a script which connects to each esx and which launches a service restart command like

Connect-viserver vcenter1 -user root -pass password

$report = foreach($esx in Get-VMHost){

   Restart-VMHostService -HostService ( $_ | Get-VMHostService | Where { $_.Key -eq "ntpd" } )

}

- or a planified task in vcenter but the option is not active i think because a can edit run a task but not add a task.

So

what is your opinion and the possibilities ?

Thank you

10 Replies
scott28tt
VMware Employee
VMware Employee

Options for vCenter Server task scheduling: Create a Scheduled Task


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

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
CG21
Enthusiast
Enthusiast

I don't have this option;

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

Using the vSphere Web Client?

Log In to vCenter Server by Using the vSphere Client


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

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
CG21
Enthusiast
Enthusiast

yes look the attachment

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

That's the vSphere Client.

The documentation I linked to refers to the vSphere Web Client:

Screenshot 2020-04-06 at 16.35.14.png

Which you can launch like this:

Screenshot 2020-04-06 at 16.35.41.png


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

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
CG21
Enthusiast
Enthusiast

HI,

thanks actually I can via sphere-client configure a scheduled task, but my goal was to plan a daily restart of the ntp service

and the option is : - create a new vm or - search new update

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

In which case you'll need some other type of task scheduler to run your custom script, something more generic such as the schedulers in Windows, Linux, or macOS.


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

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
CG21
Enthusiast
Enthusiast

correct i will re-direct my question in the powercli forum.

thank you for your help

NathanosBlightc
Commander
Commander

If you want to achieve this via the PowerCLI, run the command like the following (for example for the SSH service):

Get-VMHost | Foreach {Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} )}

Please mark my comment as the Correct Answer if this solution resolved your problem
Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

Moderator: Thread locked as a duplicate has now been created in the PowerCLI area.


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

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos