Get "octopus Deploy" endpoint details from vsts using powershell

Need help in Get-Serviceendpoint details of the vsts projects using powershell.

E.g: --vsts project
Service endpoint = “octopus deploy” (need powershell for this"

And replace the endpoint url with updated one.

Hi Ramya,

Thanks for getting in touch,

I’m not exactly clear on the subject of your request. Could you clarify the question a bit? It seems like your question is more about VSTS than about Octopus, but it’d be good to get that cleared up before I try to offer an answer.



I need to replace the “Octopus deploy” endpoint details for all projects in VSTS account with new URL with existing one.

Already we have the endpoint details updated in Service endpoints in VSTS project settings. I need to get the details of that and also replace the old one with new one using rest API.

OK, so that’s a little more clear.

Since the question is about VSTS and not really specific to Octopus, it’s a little outside our normal support boundaries. I’d really advise getting in touch with the VSTS support team for this question, but here’s what I could glean from the public documentation:

Step 1: you’ll need to enumerate your projects

For this you’ll need the Projects API, documented here

Step 2: you’ll need to check the current endpoint for “Octopus Deploy” on each of those projects

For this you’ll need one of the service endpoints API methods

Step 3: you’ll need to update that endpoint’s value if it’s incorrect

For this you’ll need the update endpoint

To do this in powershell: I’d probably recommend using the vsteam Powershell module (Install-Module vsteam) if you’re not already using it.

First, you’ll need to use Add-VSTeamAccount to set up authentication for the module, then you can start actually using the module.

There is a Get-VSTeamProject cmdlet, a Get-VSTeamServiceEndpoint cmdlet, and an Update-VSTeamServiceEndpoint cmdlet, which should cover the three steps listed above.

This is very rough, very untested sketch code, but you should end up with something that looks like this:

# get projects
$projects = Get-VSTeamProject

# loop projects
$projects | % {
    # get endpoint
    $octopusEndpoint = Get-VSTeamServiceEndpoint -ProjectName $_.ProjectName | ? { $_.Name -eq "Octopus" }

    #get endpoint by ID
    $currentEndpoint = Get-VSTeamServiceEndpoint -ProjectName $_.ProjectName -id $octopusEndpoint.Id

    #check endpoint
    if($currentEndpoint.Url -ne "" )
        # update endpoint
        Write-host "Endpoint $($currentEndpoint.Url) needs to be changed"
        Update-VSTeamServiceEndpoint -ProjectName $_.ProjectName -id $ -object @{url = ""} -Verbose

This code is absolutely not tested, it’s just a rough idea of what it should probably look like. As I said at the top, you should probably contact VSTS support if you’re unsure about this.



Thank you this helped me a lot

1 Like