Created
April 6, 2015 14:12
-
-
Save Dalmirog-zz/c9b72f770a761629d5fa to your computer and use it in GitHub Desktop.
Get random tentacle from environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Config | |
$apiKey = "YourAPIKey" #eg API-YHJACKVMRLFXBAUEREQWWFKXALQ | |
$octopusURL = "YourOctopusURL" | |
$environmentName = "YourEnvironmentName" | |
$header = @{ "X-Octopus-ApiKey" = $apiKey } | |
##Process | |
$environments = Invoke-RestMethod "$OctopusURL/api/Environments/all" -Method get -Headers $header | ?{$_.name -eq "$environmentName"} | |
$machines = (Invoke-RestMethod "$OctopusURL$($environment.links.Machines)" -Method Get -Headers $header).items | |
$RandomMachine = $machines[(get-random -Maximum $machines.Count)] | |
$RandomMachine.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment