We use the stop-service cmdlet to kill several services on our mailboxes. Most of the time it works fine, but we have one or two services (who isnβt?), Which sometimes do not play well.
In this case, one of the services in question will remain in a stopped state, and the cmdlet will display this on the console again and again:
[08:49:21]WARNING: Waiting for service 'MisbehavingService (MisbehavingService)' to finish [08:49:21]stopping... [08:49:23]WARNING: Waiting for service 'MisbehavingService (MisbehavingService)' to finish [08:49:23]stopping... [08:49:25]WARNING: Waiting for service 'MisbehavingService (MisbehavingService)' to finish [08:49:25]stopping...
In the end, we have to kill the service in the task manager, and then the script.
Is there a way to refuse the stop-service cmdlet or timeout after a certain point? I believe we can check later, and if the service is still running, use the kill-process cmdlet to provide the final chop.
powershell windows-services cmdlet
larryq
source share