Query all of the Octopus targets

Hi there,

Let me begin by saying that I am a novice octopus and powershell user, thus I would like to apologize in advance if this question is too vague.
I’ve been assigned a task to write a powershell script that can query all octopus targets and where there is a service down, restart that service. I understand how to restart a service in powershell (‘Restart-Service’), however; I am not sure how I can query all octopus targets within powershell, is there a guide available on the site? is this even possible?

Thank you.

Could you add a custom script to the health check that Octopus automatically does that would check for the service and start it if present

Look here for more info

Hi Russell,

Thank you for getting in touch. Could you please expand on what information you are trying to get out of octopus? Are you interesting in whether the Tentacles are running (ie healthy), or just want to know all the machines that are connected to octopus so that you can connect to them and check another service?

If you are unsure of what you want, let me know where you can find the information in the UI, and I can point you to the right API. You can find the API documentation here.

Also look at http:///api (example and you can browse the API from your web browser.

I would recommend having a look at OctoPosh module for PowerShell, it provides some great commandlets for Octopus. Also checkout our PowerShell samples.

If you are more familiar with C#, you could write your script using LinqPad, ScriptCS or a console app and use Octopus.Client.