Skip to content

Real Life Scenarios

Dalmiro edited this page May 6, 2016 · 5 revisions

###Deleting offline Targets/Machines from Octopus

You setup a few machines in the cloud, installed the Tentacle client on them and registered them in Octopus. Once you de-provision this machines from the cloud, the Tentacle resource registered in the Octopus server will still be there, and Octopus will still try to connect to the (now deprecated) machine.

Using this combination of Octoposh cmdlets, you can

$OfflineMachines = Get-OctopusMachine -ResourceOnly | ?{$_.Status -eq "Offline"}

#Get offline machines from a specific environment
#$OfflineMachines = Get-OctopusMachine -ResourceOnly -EnvironmentName MyEnvironmentName | ?{$_.Status -eq "Offline"}

#Get Offline machines that share a specific string on their name (i.e "Test_*")
#$OfflineMachines = Get-OctopusMachine -ResourceOnly -MachineName Test_* | ?{$_.Status -eq "Offline"}

Remove-OctopusResource -Resource $OfflineMachines #add -Force to avoid being prompted for each target
Clone this wiki locally