By doing a GET
to /api/machines/all
you'll get a list of all the Machines registered in Octopus. Each of them will look a bit like this:
{
"Id": "Machines-28",
"Name": "T1Listening1",
"Thumbprint": "5B39B11EA8804D9E02E8D10189343074891BED21",
"Uri": "https://ny-tentacle1:10933/",
"IsDisabled": false,
"EnvironmentIds": [
[Edited - List of Ids]
],
"Roles": [
"WebServer"
],
"Status": "NeedsUpgrade",
"HasLatestCalamari": true,
"StatusSummary": "This machine is running an old version of Tentacle (3.2.23).",
"Endpoint": {
[Edited - Repeated info. Removed it to avoid the noise]
},
"Links": {
"Self": "/api/machines/Machines-28",
"Connection": "/api/machines/Machines-28/connection"
}
},
The value you are looking for would be "Name": "T1Listening1"
.
What you could do is:
all of this would happen per Machine from the console script
1)GET
all the machines into an array from /api/machines/all
- Get the computer name or the IP used to register in Octopus, and match it with on of the machines in the array of (1).
For example if you used the machine name to configure it in Octopus, you could use $env:computername
which in my example above would return ny-tentacle1 and then match that string with the URI property of one of the machines in the array. Then simply get the Name property of that machine. The same kind of JOIN could be achieved with the Machine's IP or even the Thumbprint with a bit more of work.