Get Machine Roles for target machine using commands


I’m looking for an easy way to get all the roles a machine currently has (without using the GUI).
I thought i’d be able to complete this with Octo.exe but i haven’t been able to.

I want to sync up our monitoring and OD so that the roles in OD directly link with the monitoring required for the deployed packages.
So i want a want to collect each machines’ roles with a command so that i could pass this to the monitoring agent.

Any help is appriciated

Hi Mark,

Indeed there is! You can use the REST API to retrieve this information easily. The machine resource available at /api/machines?name=[MachineName] will give you plenty of information about a machine, including its roles:

  "Id": "Machines-1",
  "EnvironmentIds": [
  "Roles": [

For example, if your Octopus Server UI is available at https://octopus.mycompany.local/app#/ and the machine you are looking for is DWebApp01 then your URL would be https://octopus.mycompany.local/api/machines?name=DWebApp01

You can use this API from a browser which is already logged into Octopus without needing to worry about authentication, otherwise you’ll need to create an API Key and provide that when making the request.

You can find some more useful information in our API documentation.

I hope that helps!


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.