Running a Health Check on a Single deployment target using the REST API


I would like to know whether it is possible to run a Health Check on a Single deployment target using powershell and the REST API.

I know how to run a Health Check to an Environment or a machine in an Environment but the problem is that we could have 100+ targets in 1 environment and I dont want to run a Health Check to all machines.

Basically, I just need to do the exactly what you would do in the UI by selecting the deployment target and going to connectivity and running the health check.

I would like to add that I am using Octopus 3.0.23.

I am sorry if this question has been asked before but I couldn’t find anything relevant.

Thanks in advance.


Thanks for reaching out. Here’s a script to do that:

Hope it helps


Thanks bud. That’s exactly what I was looking for.

Just incase anyone would like a Script that uses the machine name rather than the machine ID. Here you go.

I have tested this with our stuff an it works. Do you have any comments on this Dalmiro?

$OctopusURL = “”
$OctopusAPIKey = “”
$MachineName = “” #Machine Display Name
Add-Type -Path “” # Path to Octopus.Platform.dll
Add-Type -Path “” # Path to Newtonsoft.Json.dll
Add-Type -Path “” # Path to Octopus.Client.dll
$endpoint = new-object Octopus.Client.OctopusServerEndpoint $OctopusURL,$OctopusAPIKey
$repository = new-object Octopus.Client.OctopusRepository $endpoint
$findmachine = $repository.Machines.FindByName("$MachineName")
$machineid = $

$header = @{ “X-Octopus-ApiKey” = $OctopusAPIKey }

$body = @{
Name = "Health"
Description = "Checking health of $MachineName"
Arguments = @{
Timeout= "00:05:00"
MachineIds = @($machineId)
} | ConvertTo-Json

Invoke-RestMethod $OctopusURL/api/tasks -Method Post -Body $body -Headers $header

HI Lance,

I must admit I was a bit lazy back then, and I should have made the script so the user could find the machine by Name instead of an un-intuitive ID. I’ve updated the script in the Github project to look just like yours :slight_smile:



No worries.

Thank you for being willing and open to suggestions.