Powershell - Get WebApp Target


I’m currently using New-OctopusAzureWebAppTarget PowerShell cmdlet to create a WebApp Target dynamically inside a deployment. Thing is, if the WebApp Target already exists, the whole step fails.

Would there be a way to check if the target already exists or use some cmdlet like Get-OctopusAzureWebAppTarget (which doesn’t exist as of v2018.10.0 LTS)? I tried using a Try-Catch in my script to catch the error but it hasn’t even got in the catch statement.

What would you recommend using in this case?

Thanks and regards,
Etienne Huckle-Marchand

Hi @etienne.huckle-marchand,

Thanks for getting in touch!

Will I’m not 100% if this will fill your need, you can add the -updateIfExisting switch when using New-OctopusAzureWebAppTarget which will do exactly as it states, specifically create a target if it doesn’t exist, and if it does it will update with new parameters.

If there is another case that you need handled please let me know and I’ll investigate further.


Hi @Alex.Rolley,

Well, you were right! :grin: -updateIfExisting is exactly what I needed.

Thank you so much!