Mass connect multiple tenants to single project though Cli


I am trying to figure out if I can connect multiple tenants to a single project though the cli or if I will need to script this out with powershell. Does anyone know if this is possible?

This would be very helpful as I have over 1000 tenants that will need to be individually connected to two different projects. I really dont want to manually click through all of them in the web gui.

Please let me know your thoughts!



Yes, that is absolutely possible with the Octopus Deploy Rest API. I need to whip up a quick script as a sample you can modify to fit your needs, but I should have something for you tomorrow.

Question: is it all of your tenants, or a subset of them? Are they grouped via tenant tag?

1 Like


Thanks so much for your fast response!!! I really appreciate your offer to help me find my way along the right path here!

We have all of our customers tagged as tenant type Customer so that would be amazing if I could connect all of those tags to the 2 projects I need to connect them to!

Thank you so much for any help you send my way! :smiley:

Cool, having the ability to filter makes things a bit easier.

I put a sample script up on our docs: Bulk add a project to a list of tenants - Octopus Deploy

A few notes about the script:

  • The syntax for tenant tag is [Tenant Tag Set Name]/[Tenant Tag Name], for example Tenant Type/Customer.
  • It has a what-if switch, you can set that to true to test out anything. It won’t save to your instance.
  • It has a max number of tenants to change. Set that to 10-15 to test things out for a small handful of tenants before letting it rip.
  • It prints out a changelog of what it would’ve done (when it what if mode) or what it did (when not in what-if mode)
  • It will ensure all the environments specified are assigned to the project/tenant relationship. If you specified 2 environments and had a pre-existing tenant/project relationship with only 1 environment it will add the second environment.
  • It doesn’t take into account variables because…yikes! (The scripts to change tenant variables is quite…complex to write)

I hope that helps!

1 Like

Wow!! This is amazing! Thank you so much for putting that together for us! I will test it out in our lab environment later today but this will be so helpful! Thank you so much!!! :smiley:

You are welcome! It actually triggered an internal conversation within in the team. I think we are going to add more bulk functionality examples like this in our docs. I do think we need to ad it to the UI, but this will be a good alternative until then.

I would recommend running it for 25-50 tenants at a time instead of the full 1000, just to be safe (easier to undo 25-50 tenants vs 1000) :slight_smile:

1 Like

Hey Bob,

For some reason I can’t get it to go passed line 171 :frowning:

It just keeps saying cannot find space with name of Default but this is our only space name. Any advice would be greatly appreciated!

The pulling back of the space id from the space name is one of the first items this script does.

Because of that, I’m leaning towards a permissions issue or a URL issue.

Have you verified the user associated with the API key has view permissions to all spaces? Also, the script expects the URL to be in the format of “” not “” or “”

1 Like

This literally MADE MY DAY!!! I was able to get it to work flawlessly! Now im eager to learn more PowerShell! THANK YOU SO MUCH!!! You are AWESOME!

You are welcome! Happy to help out! Enjoy the rest of your week!