Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: How do I list machine names and a service state in a loop please?

$
0
0

I don’t think so… What Martin has written will work on a remote machine. Remember that the object being sent through the pipeline represents a specific service on a remote computer because that’s what you requested with Get-Service. Therefore when you pipe that object to Restart-Service it knows what to do.

I can show another way this can be done, and in my opinion a little simpler, understandable and of course much less code.

Get-Service -Name SCardSvr -ComputerName $(get-content C:\Users\someguy\Documents\playmachines.txt) | Restart-Service -PassThru | Select-Object Status,Name,DisplayName,MachineName

Viewing all articles
Browse latest Browse all 13067

Trending Articles