If you have created a number of Azure DevOps Service Connections, you might start to see a list like this (I’ve blanked out all the GUIDs) that becomes not only tricky to manage but difficult to read and understand what their end use is.
For all of this, you should be using Powershell 7+.

If you are trying to keep all things handy dandy and managed in one place, where you don’t need to manually go and change these things from the UI, you can accomplish this task with AZ DevOps.
Note: You cannot make this change using the az devops update for service connections.
Retrieve your Service Connection(s)
If you haven’t already, you can use az-login to login to your Azure DevOps environment. Once complete, we’ll want to retrieve the list of service connections we have to choose from using the following command
az devops service-endpoint list --organization https://dev.azure.com/#ORG% --project #PRJNAME# -o table
From there, you’ll get back a list of services in that project. You will want to make note of the ID here.
Download the Service Connection you want to update
From here, we are going to use similar az devops commands, but instead of calling direct member functions, we are going to be making calls to the service endpoint rest API to do our work for us.
az devops invoke --organization https://dev.azure.com/#ORG$/ --area serviceendpoint --resource endpoints --route-parameters "project=#PROJECT#" "endpointId=1508fda0-137f-415d-1175-ff3772431140" --http-method GET -o json > devops.json
The above statements connects to the DevOps REST API and downloads a JSON representation of the service endpoint. The endpoint Id is the Id we saved from our previous step.
Note: Pay special attention to the use of route-parameters and how you set your parameters, this tripped me up for quite awhile.
Make your Changes
From here, you can open the file and make your change (or parse the JSON). In this case, we are only changing the name, so that’s all I updated. If you want to keep the original, you can make a copy of the file (as I did, calling mine patcheddevops.json).

Format your Submission for UTF-8
I don’t know if it’s classified as a bug, but there is a difference between how Powershell encodes files and other editors. For your JSON file to be handled properly, you need to re-encode it as UTF-8; otherwise, the rest endpoint will not know how to handle it, and it will send back error after error.
Get-Content patcheddevops.json | Out-File -FilePath patcheddevopsut8.json -Encoding UTF8
Submit your changed File
Using the following command, you can push your changes back into DevOps. In the documentation, I found references to the use of PATCH, however, this did not work, and PUT was definitely the way to go.
az devops invoke --organization https://dev.azure.com/#ORG$/ --area serviceendpoint --resource endpoints --route-parameters "project=#PROJECT#" "endpointId=1508fda0-137f-415d-1175-ff3772431140" --http-method PUT --in-file patcheddevopsut8.json
When you return to your Azure DevOps page, you will see the changes reflected on the page.
