I am deploying a web site using power script, server is running on windows 7 with IIS 7.5
I am using following code to deploy the application $arguments = [string[]]@(
"-verb:sync",
"-source:package='$PackagePath'",
"-dest:auto,computerName='$PublishUrl',AuthType='NTLM'",
"-setParam:name='IIS Web Application Name',value='$($WebApp)'",
"-allowUntrusted")
Start-Process $msdeploy -ArgumentList $arguments -NoNewWindow -Wait
above script is working fine.
I want to catch the negative case.When I disable the web deploy agent service on the machine,it throws a message (Power shell is not treating this as error or exception)
Error Code: ERROR_COULD_NOT_CONNECT_TO_REMOTESVC
More Information: Could not connect to the remote computer ("localhost") using the specified process ("Web Deployment Agent Service") because the server did not respond. Make sure that the process ("Web Deployment Agent Service") is start ed on the remote computer. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMO TESVC.
Error: The remote server returned an error: (503) Server Unavailable.
Error count: 1.
How can I catch this in powershell.