Query all of the Octopus targets

Russell's Avatar

Russell

17 Jul, 2017 03:54 PM

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.

  1. 1 Posted by Richard on 17 Jul, 2017 04:18 PM

    Richard's Avatar

    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

  2. Support Staff 2 Posted by Robert Wagner on 17 Jul, 2017 11:26 PM

    Robert Wagner's Avatar

    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.

    Rob

  3. Paul Stovell closed this discussion on 01 Nov, 2017 09:28 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac