Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过PowerShell创建Azure DevOps服务连接终结点_Powershell_Azure Devops_Azure Devops Rest Api_Serviceconnection_Azure Rest Api - Fatal编程技术网

如何通过PowerShell创建Azure DevOps服务连接终结点

如何通过PowerShell创建Azure DevOps服务连接终结点,powershell,azure-devops,azure-devops-rest-api,serviceconnection,azure-rest-api,Powershell,Azure Devops,Azure Devops Rest Api,Serviceconnection,Azure Rest Api,我想知道是否可以编写PowerShell来创建Azure DevOps服务连接端点 我想通过访问Azure DevOps来限制每个人对创建服务连接端点的访问,我们需要创建多个服务连接端点,包括UnitTesting工具的连接端点、构建工具、自动化测试工具,然后是docker工具 我可以通过使用PowerShell的Azure DevOps Rest API读取已经创建的Azure DevOps服务连接端点(调用RestMethod-Method get-Header),但是我想知道是否可以通过将

我想知道是否可以编写PowerShell来创建Azure DevOps服务连接端点

我想通过访问Azure DevOps来限制每个人对创建服务连接端点的访问,我们需要创建多个服务连接端点,包括UnitTesting工具的连接端点、构建工具、自动化测试工具,然后是docker工具

我可以通过使用PowerShell的Azure DevOps Rest API读取已经创建的Azure DevOps服务连接端点(
调用RestMethod-Method get-Header
),但是我想知道是否可以通过将服务端点信息作为主体传递给Rest API,使用相同的Rest API创建新的服务连接端点(
调用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')"
有可能:

请求正文,例如(对于Azure端点):

有可能:

请求正文,例如(对于Azure端点):


谢谢@Shayki Abramczyk。我能够将Json转换为powershell readable,这很有效。谢谢@Shayki Abramczyk。我能够将Json转换为powershell readable,这很有效。
POST https://dev.azure.com/{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=5.1-preview.2
{
  "data": {
     "SubscriptionId": "21312421-4123-1323-3123-12534543",
     "SubscriptionName: "TestSub"
  },
  "id": "2e344hjds-23ds-242fs-42ds-dsfsdaf34s",
  "name": "TestEndpoint",
  "type": "Azure",
  "authorization": {
    "parameters": {
       "Certificate": "dummyCertificate"
     },
     "scheme": "Certificate"
  },
  "isReady": false
}