How To create Tenants with Powershell API

Do you have any examples or documentation on the powershell API?. I would like to use the $repository.Tenants.Create() method to create tenants, but I don’t know what parameters to pass. I need to create a tenant, add the appropriate tenant tag, and assign it to existing projects & environments.

thanks.

same question for $repository.Machines.Create()

Hi!

Thanks for getting in touch! Probably the best way is to use what we call our Editor API which is a fluent-style API baked into the Octopus Client SDK. Provided you are using a reference to the Octopus.Client.dll in your PowerShell script you should be able to do something like this: https://github.com/OctopusDeploy/Sampler/blob/master/source/Sampler/Commands/MultiTenantSampleCommand.cs#L298

If for some reason those methods aren’t available, you may need to update the version of the Octopus Client you are using.

I would recommend cloning that repository and walking through that code yourself to see which pieces you want to steal. :slight_smile:

Hope that helps!
Mike