short version: how do I get Octopus to ignore an error raised by “net stop” or “net start” during a powershell script? (try/catch doesn’t work)
longer version:
We have a project that has steps that stop and later start a windows service. this service has issues, however, and when we execute “net stop XYZ” or “net start XYZ”, it doesn’t always run clean, and will often return an error message. regardless, the service does eventually stop or start.
so, I’ve written a loop that, after issuing the “net stop” or “net start” command, monitors the service’s status using “Get-Service”, checking every 5 seconds, and proceeding when the service finally stops or starts. that part is working.
however, when the “net stop” or “net start” appear to fail, it outputs a red error messages, and thus the powershell step is reported back to Octopus as Failed, even though it has actually run successfully.
How do I get Octopus to ignore an error raised in the powershell script? (surrounding the “net stop” or “net start” in a try/catch block does not help.)
This does not work for me. How can i suppress this error?
Tentacle script execution
Error 10:37:15
start-webitem : The service cannot accept control messages at this time.
Error 10:37:15
(Exception from HRESULT: 0x80070425)
Error 10:37:15
At C:\Windows\system32\config\systemprofile\AppData\Local\Tentacle\Temp\61c0488
Error 10:37:15
5-08d1-482a-b43b-df162a4a6a58.ps1:9 char:1
Error 10:37:15