Last active
October 19, 2015 16:48
-
-
Save Dalmirog-zz/d5a90737dd9926bf7101 to your computer and use it in GitHub Desktop.
Getting projects using the 3 methods
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
#Using Octopus.client (recommended if you are planning on automating more than just this simple GET in the future) | |
# You can get this dll from your Octopus Server/Tentacle installation directory or from | |
# https://www.nuget.org/packages/Octopus.Client/ | |
Add-Type -Path 'Octopus.Client.dll' | |
$apikey = '' | |
$octopusURI = '' | |
$endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURI,$apikey | |
$repository = New-Object Octopus.Client.OctopusRepository $endpoint | |
$projects = $repository.Projects.findall() | |
$projects | |
#Using Octoposh, an open source project that uses the Octopus API to automate many Octopus' tasks. More than recommended if you're gonna keep using the API to automate processes. | |
#Get-Octoposh -> http://dalmirog.github.io/OctoPosh/ | |
#Wiki with list of all cmdlets -> https://github.com/Dalmirog/OctoPosh/wiki | |
$projects = Get-OctopusProject | |
$projects | |
#Using RAW API and invoke-webrequest | |
$OctopusURL = "" | |
$OctopusAPIKey = "" | |
$header = @{ "X-Octopus-ApiKey" = $OctopusAPIKey } | |
$Projects = (Invoke-WebRequest $OctopusURL/api/projects -Headers $header).content | ConvertFrom-Json | Select -ExpandProperty Items | |
$Projects |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment