这些TFS(内部部署)REST URL所需的权限?

这些TFS(内部部署)REST URL所需的权限?,rest,tfs,Rest,Tfs,我正在尝试自动化一些需要有关代理池和代理的信息的作业,虽然作业脚本对于我的TFS集合的普通用户来说工作正常,但对于服务帐户来说,它却失败得很惨 我的作业脚本尝试访问URL http://<instance>/<collection>/_apis/distributedtask/pools http://<instance>/<collection>/_apis/distributedtask/pools/<pool>/agents 表

我正在尝试自动化一些需要有关代理池和代理的信息的作业,虽然作业脚本对于我的TFS集合的普通用户来说工作正常,但对于服务帐户来说,它却失败得很惨

我的作业脚本尝试访问URL

http://<instance>/<collection>/_apis/distributedtask/pools
http://<instance>/<collection>/_apis/distributedtask/pools/<pool>/agents
表示缺少许可

我尝试将服务帐户添加到TFS中的各个组,如项目集合管理员、项目集合生成管理员等,但都没有成功


因此,简而言之,服务帐户需要什么权限才能从开始中提到的URL检索信息?

我可以重现这个问题,它甚至无法将普通用户更改为服务帐户

因此,现在作为一种解决方法,您可以使用常规用户或脚本中的PAT调用RESTAPI

下面的PowerShell脚本适用于我:

$user = "Domain\username"
$token = "password"

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$uri = "http://SERVER:8080/tfs/_apis/distributedtask/pools/1/agents/5"
$result = Invoke-RestMethod -Uri $uri -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}

Write-Host "result = $($result | ConvertTo-Json -Depth 100)"

是的,那会奏效,但由于公司政策的原因,这对我来说是不可行的。@MichaelWraa Hansen PAT呢?您可以为用户和密码或PAT创建秘密变量,然后在脚本中使用这些变量。我想我可以将其用作临时解决方案,但由于无法获得适当的解决方案,我认为无论密码保存在何处都不行。经常更改用户密码的要求也会造成麻烦。PS:如果有必要,我正在使用TFS17更新2。
no agents are registered or you do not have permission to view the agents 
$user = "Domain\username"
$token = "password"

# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$uri = "http://SERVER:8080/tfs/_apis/distributedtask/pools/1/agents/5"
$result = Invoke-RestMethod -Uri $uri -Method Get -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}

Write-Host "result = $($result | ConvertTo-Json -Depth 100)"