<p>The <code>-name</code> parameter of the <code>Stop-Service</code> command is an [array strings][1]. You can pass multiple services to it.</p>

<pre><code>Stop-Service -name service1,service2,service3
</code></pre>

<p><strong>Edit</strong></p>

<pre><code>[string[]]$services = @('service1', 'service2')
Stop-Service -Name $services -NoWait
while ((Get-Service -Name $services | Where-Object { $_.status -ne 'Stopped'}).Count -ne 0)
{
    Start-Sleep -Seconds 5
}
</code></pre>

CC BY-SA 4.0
2020-02-21T06:59:37.983Z
I have tried this command, but it's not stopping services at the same time. I am getting below output.

`WARNING: Waiting for service 'MyFirstService1 (MyFirstService1)' to stop...
WARNING: Waiting for service 'MyFirstService1 (MyFirstService1)' to stop...`
ankit thakkar
CC BY-SA 4.0
2020-02-21T07:54:01.570Z
@ankitthakkar - I misunderstood your requirement. In that case, you can not use Stop-Service like this. You'd have to wrap each stop service in a job or async procedure but even then, you can never be sure they all stop **at the exact same time**. Each will get **a stop command** at around the same time though.
Lieven Keersmaekers
CC BY-SA 4.0
2020-02-21T08:51:15.903Z
I am using the stop-service command to stop all the service by using -NoWait but I also want that it will not move to the next step till all services will stop.
ankit thakkar
CC BY-SA 4.0
2020-02-21T09:34:14.323Z
In that case, you can write a loop to check if all services are stopped. I have added this to my answer
Lieven Keersmaekers
CC BY-SA 4.0
2020-02-21T11:41:55.643Z
I have resolved this using loop and `WaitForStatus` Argument of service.
ankit thakkar
CC BY-SA 4.0
2020-02-21T11:42:27.590Z
Thanks @Lieven for your support !!!
ankit thakkar
CC BY-SA 4.0
2020-02-21T12:23:38.040Z
@ankitthakkar - You are welcome. I didn't know `WaitForStatus` myself.
Lieven Keersmaekers
CC BY-SA 4.0
2020-02-21T06:47:50.130Z
2020-02-21T09:50:10.770Z
2020-02-21T09:50:10.770Z
Lieven Keersmaekers
<p>I have multiple windows service and there are no dependencies between them. I want to stop all the windows services at the same time. I don't want to stop all the services one by one. How can I achieve this?</p>

<powershell>
Stop Multiple Windows Service Simultaneously
ankit thakkar
# Stop Multiple Windows Service Simultaneously

(Asked by: username_0 on 2020-02-21)

I have multiple windows service and there are no dependencies between them. I want to stop all the windows services at the same time. I don't want to stop all the services one by one. How can I achieve this?

**Tags:** powershell


---

## 1 answers

### Answer by username_1 on 2020-02-21. Score: 1

The -name parameter of the Stop-Service command is an [array strings][1]. You can pass multiple services to it.
Stop-Service -name service1,service2,service3

Edit
[string[]]$services = @('service1', 'service2')
Stop-Service -Name $services -NoWait
while ((Get-Service -Name $services | Where-Object { $_.status -ne 'Stopped'}).Count -ne 0)
{
    Start-Sleep -Seconds 5
}

> **Comments:**
> **username_0**: I have tried this command, but it's not stopping services at the same time. I am getting below output.  `WARNING: Waiting for service 'MyFirstService1 (MyFirstService1)' to stop... WARNING: Waiting for service 'MyFirstService1 (MyFirstService1)' to stop...`  
> **username_1**: @ankitthakkar - I misunderstood your requirement. In that case, you can not use Stop-Service like this. You'd have to wrap each stop service in a job or async procedure but even then, you can never be sure they all stop **at the exact same time**. Each will get **a stop command** at around the same time though.  
> **username_0**: I am using the stop-service command to stop all the service by using -NoWait but I also want that it will not move to the next step till all services will stop.  
> **username_1**: In that case, you can write a loop to check if all services are stopped. I have added this to my answer  
> **username_0**: I have resolved this using loop and `WaitForStatus` Argument of service.  
> **username_0**: Thanks @Lieven for your support !!!  
> **username_1**: @ankitthakkar - You are welcome. I didn't know `WaitForStatus` myself.  

---

