But by doing it like that, you are getting the services from the Remote computer and piping them to Restart-Service (or Start/Stop-Service) on Your computer, and restarting the service on Your LOCAL computer, not on the target computer.
Restart-Service, Start-Service and Stop-Service only Works on the local maschine.
It doesn’t have a -ComputerName parameter (check the help file)
I think you need to use WMI/CIM for this, or use:
Invoke-Command -ScriptBlock {Restart-Service -Name BITS } -ComputerName SomeComputer
to run the command on the Remote computer.
↧
Reply To: How do I list machine names and a service state in a loop please?
↧