Adding environments into Octopus Server using script

Hi, Can you please help us with the powershell script to add bulk environments into Octopus Server instead of creating each environment from the UI.

Hi Pratik,

For information about the API, see our documentation. For PowerShell, there is OctoPosh, which also has examples on how to create and modify resources.

Robert W

Hi Robert, Thanks for your response.
However i am struggling to find the answer to me query from the links.
Request your help to add bulk environments into Octopus Server.
For example,I need to add below environments all at once.
Environment_1
Environment_2
.
.
.
Environment_100

Hi Pratik,

Here is the documentation on how to create an environment using OctoPosh.

Robert W

Thanks a lot Robert for speedy response :slight_smile:

When I try to execute command for creating listening tentacle, it gives below error:
Get-OctopusResourceModel : The term ‘Get-OctopusResourceModel’ is not recognized as the name of a cmdlet, function,
Can you please help me to know from where do i need to execute this script?

Have you installed the module?

i tried to, but it says the module to process OctoPosh.dll was not found.
I downloaded Octoposh-Master and extracted it to C:\program files\windowspowershell\modules but no help.

Does it require Powershell 5.0 ? Please confirm.
Because to install OctoPosh, website states that it needs Powershell 5.0
So I cannt do it on Powershell 4.0 and hence i cannt run the script to add Environments/tentacles using script?

PowerShell 5.0 is required for the first method of installation. The second should work on PowerShell 3 and later.

Did you follow all the steps? ie Unblock. Can you show me the contents of your C:\program files\windowspowershell\modules\OctoPosh folder?

Can you copy in the exact output?

If you can’t get Powershell working, you can use the API directly, or the C# client. It is detailed in the links above.