Powershell exit of zero

Hi,

I’m having some trouble wondering why this is happening. I have a powershell script which stop-app pools, but because i’m deploying multiple websites which are on the same app pool, i added

Write-Host "Stopping App Pools!"
Stop-WebAppPool $ApplicationPoolName -ErrorAction SilentlyContinue)

With the ErrorAction you would expect the script to continue? even if the stop-web fails?
with my deployment I receive

2013-05-28 11:42:54 INFO   [PreDeploy Script]   Stopping App Pools!
2013-05-28 11:42:54 INFO   [PreDeploy Script]   ERROR: Stop-WebItem : Object on target path is already stopped.
2013-05-28 11:42:54 INFO   [PreDeploy Script]   ERROR:     + CategoryInfo          : InvalidOperation: (:) [Stop-WebItem], InvalidOpe
2013-05-28 11:42:54 INFO   [PreDeploy Script]   ERROR:    rationException
2013-05-28 11:42:54 INFO   [PreDeploy Script]   ERROR:     + FullyQualifiedErrorId : InvalidOperation,Microsoft.IIs.PowerShell.Provid
2013-05-28 11:42:54 INFO   [PreDeploy Script]   ERROR:    er.StopItemCommand
2013-05-28 11:42:54 INFO   [PreDeploy Script]   ERROR:
2013-05-28 11:42:54 WARN   [PreDeploy Script] The script returned an exit code of 0, but output was written to the error output       stream. Please investigate any errors in the script output above. 

Thoughts, or do you know the reasoning behind it?

Stop-WebAppPool $ApplicationPoolName -ErrorAction SilentlyContinue

^ sorry no ) at the end.

Hi Lewis,

We set an ErrorActionPreference of Stop when your script starts, but I would have expected -ErrorAction to override this. You could try changing this value.

Paul