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

0 Kudos
CG21
Enthusiast
Enthusiast

I don't have this option;

0 Kudos
scott28tt
VMware Employee
VMware Employee

0 Kudos
CG21
Enthusiast
Enthusiast

yes look the attachment

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

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

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.

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
0 Kudos
scott28tt
VMware Employee
VMware Employee

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

0 Kudos