title: Stopping & Restarting Services Remotely Using Set-Service
body: <p>I've got a list of 10-15 services that I routinely need to restart on 6 servers. I have a script that calls a list of services, then calls a list of the servers, and then stops all the services:</p>
  
  <pre><code>$Services = Get-Content -Path "C:\Powershell\Services.txt"
  $Machines = Get-Content -Path "C:\Powershell\Machines.txt"
  Get-Service -Name $Services -ComputerName $Machines | Set-Service -Status Stopped
  </code></pre>
  
  <p>I then have another separate script to start them up again:</p>
  
  <pre><code>$Services = Get-Content -Path "C:\Powershell\Services.txt"
  $Machines = Get-Content -Path "C:\Powershell\Machines.txt"
  Get-Service -Name $Services -ComputerName $Machines | Set-Service -Status Running
  </code></pre>
  
  <p>I've checked around and can't seem to find a way of putting this into a single script. As I understand, Set-Service only has the ability to Stop, Start &amp; Pause services, not restart them at the same time.</p>
  
  <p>Any ideas? I might be missing something completely obvious.</p>