Run PowerShell script for each tenant


We have 100+ tenants which are ASP.NET sites for each of our client. Each site has web.config file with its own connection string and other client specific settings. I want to make modifications in web.config file using PowerShell script. If I run Post Deployment Script in a Step, will it run for each tenant? Can I write relative path of web.config in my script like this?

[xml]$result = Get-Content \Web.config
$httpErrorNode = $result.configuration.'system.webServer'.httpErrors.SetAttribute('Key','Value')

Hi Qasim,

Thanks for getting in touch! When performing tenanted deployments, it executes a deployment task per tenant, so it will run for each. You can also write a relative path to the config file as it exists in your package, so your solution looks like it would work.

An alternative could be to perform config transformations on each of your tenants. This would work if you have tenant-specific transform files in your package, and Octopus will also run them automatically if the transform file names follow the convention *.<TenantName>.config. More information on configuration transforms feature and the conventions (and the order in which they’re executed) Octopus follows can be found in our documentation.

I hope this helps! Let me know if there’s anything else I can assist with moving forward. :slight_smile:

Best regards,


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.