我想知道是否可以编写 PowerShell 来创建 Azure DevOps 服务连接端点。
我想通过访问 Azure DevOps 来限制每个人创建服务连接端点的访问,我们需要创建多个服务连接端点,包括 UnitTesting 工具、构建工具、自动化测试工具和 docker 事物的连接端点。
Invoke-RestMethod <uri> -Method get -Header <myheader>
我可以通过Azure DevOps Rest API 使用 PowerShell ( ( Invoke-RestMethod
)。
这就是我获取现有服务连接端点的方式:
##Invoke-RestMethod $url -Method GET -Headers $headers -ContentType
'application/json' -Verbose
##I refer below code as Example to code to update existing work item,
this is working but for service connection endpoint, I'm having no clue:
$workitem = Invoke-RestMethod -Uri $wisUrl -Method Get -ContentType
"application/json" -Headers $header
Write-Host "Before: $($workitem.fields.'System.Title')"
$body = @"
[
{
"op": "add",
"path": "/fields/System.Title",
"value": "$($workitem.fields.'System.Title')+DEMO"
},
{
"op": "add",
"path": "/fields/System.History",
"value": "Changing Title"
}
]
"@
$workitem = Invoke-RestMethod -Uri $wisUrl -Method Patch -ContentType
"application/json-patch+json" -Headers $header -Body $body
Write-Host "After: $($workitem.fields.'System.Title')"