TFS 集成使用提升的权限构建 Powershell [英] TFS Integration Build Powershell With Elevated Privileges

查看:38
本文介绍了TFS 集成使用提升的权限构建 Powershell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置一个集成测试版本,我只是在尝试启动 Windows 服务.

I am setting up an integration tests build where I am just trying to start up a windows service.

我使用了 InvokeProcess 命令来运行 powershell 脚本,它只执行以下操作

I have used the InvokeProcess command to run the powershell scripts which just does the following

Start-Service ServiceName

当我运行构建过程时脚本失败,但是当我在 TFS 之外执行相同的脚本时它可以工作.我在 TFS 日志中收到以下错误

The script fails when I run the build process but when I executed the same script outside TFS it works. I get the following error in TFS logs

Start-Service:由于以下错误,无法启动服务ServiceName (ServiceName)":无法打开 ServiceName计算机."上的服务.

然后我尝试改变我启动服务的方式,并在 InvokeProcess 中使用带有参数 "Start ServiceName" 的 SC.exe,我在 TFS 中收到拒绝访问错误,如下所示:-

Then I tried changing the way I am starting the service and used SC.exe with parameters "Start ServiceName" in the InvokeProcess and I get Access Denied error in TFS as follows:-

SC 启动服务名称.[SC] 启动服务:OpenService 失败 5:访问被拒绝.

我正在使用网络服务帐户来运行构建.

I am using Network Service account to run the build.

搜索一段时间后,我得出的结论是,我必须以提升的权限运行 InvokeProcess,但我不知道如何在 TFS 中执行此操作.

After searching a while, I have come to the conclusion that I have to run the InvokeProcess with elevated privileges but I don't know how would I do that with in TFS.

非常感谢任何帮助.

推荐答案

我们将构建代理作为自定义服务帐户运行,并在我们部署到的服务器上授予该域帐户管理员访问权限.

We run our build agent as a custom service account and give that domain account admin access on the servers we deploy to.

这篇关于TFS 集成使用提升的权限构建 Powershell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆