So I have a script/module I want to make that will remotely stop a bunch of services simultaneously but I’ve been struggling with how to make it work. I recently (read: yesterday) learned of workflows in Powershell and thought this was the answer to my scripting-prayers-but I am still struggling with how to make it work.
The way I’m trying to go about it is to get-service from remote computer where name is like xxx-this would return anywhere from 5-20 services; I then want to make the call to stop all of those services simultaneously/in parallel.
I guess what I’m struggling with is how to use the workflow to make this happen. I’m no PS expert and the examples I’ve seen aren’t making sense to me and time is becoming more of an issue for this.
PowerShell workflows are quite challenging to work with and have lots of gotchas. It looks like PowerShell, but it’s not. And how it behaves can be different from one run to the next. Workflows are almost never worth it.
That said, the below code would work for the simple task described. But any enhancements, such as waiting, timeouts, error handling, logging, feedback, etc., could get very complicated very quickly.