A
A
Artem Kiryanov2018-06-28 14:30:28
PowerShell
Artem Kiryanov, 2018-06-28 14:30:28

How to restart a service on remote PCs using Powershell?

Hello.
There was a problem restarting the service on the remote PCs.
What I managed to do was restart with this command:
(Get-WmiObject Win32_Service -filter "name='service'" -ComputerName Server01).StopService()
(Get-WmiObject Win32_Service -filter "name='service'" -ComputerName Server01) .StartService()
But this request stops and starts the service, but you need to somehow write a restart or write a timer that, after stopping, will wait 20 seconds and restart the service on remote PCs.
Help to make a correct script or maybe there are similar requests. I didn’t find any special solutions in Google, or I didn’t search well.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question