-
-
Save espoelstra/e63e6ef9f4fc2c1a85ddb3066a4cd33e to your computer and use it in GitHub Desktop.
Executing a Script Task via the Octopus API
This file contains 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
var server = "http://yourserveraddress:8065/"; //Your server and IP address | |
var apiKey = "API-XXXXXXXXXXXXXXXXXXXXXXXXX"; // Get this from your 'profile' page in the Octopus web portal | |
var endpoint = new OctopusServerEndpoint(server, apiKey); | |
var repository = new OctopusRepository(endpoint); | |
var task = new Octopus.Client.Model.TaskResource(); | |
task.Name = "AdHocScript"; | |
task.Description = "Script invoked via API"; | |
task.Arguments.Add("MachineIds", new Object[]{"machines-129"}); //Your machine ID | |
task.Arguments.Add("ScriptBody", "Write-Host \"Hello World\""); //Or you'll probably want to read in a script body from disk | |
var result = repository.Tasks.Create(task); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment