TFS 构建:以管理员身份运行 Powershell 脚本 [英] TFS Build: Run a Powershell script as administrator
问题描述
我为我们的夜间构建服务器创建了一个构建定义.构建项目(Windows 服务)后,我需要执行一个 Powershell 脚本来安装和启动该服务.所以我添加了一个构建步骤来运行特定的 Powershell 脚本.然后我安装了一个 TFS Build Agent &Visual Studio 在(即将)每晚构建服务器上.运行构建脚本后,我得到一个退出代码 5",这似乎与缺少管理员权限有关.如果我手动在服务器上以管理员身份启动脚本,它工作正常.代理使用的用户已获得管理员权限.
I created a build definition for our nightly build server. After building the project (a windows service), I need to execute a Powershell script to install and start the service. So I added a build step to run the specific Powershell script. Then I installed a TFS Build Agent & Visual Studio at the (soon to be) nightly build server. After running the build script I got an 'exit code 5' which seems to be related to missing administratior permissions. If I start the script as admin on the server manually, it works fine. The user, which is used by the agent, already got admin permissions.
有没有办法使用具有管理员权限的构建代理/构建定义在构建服务器上执行 powershell 脚本?
Is there a way to execute the powershell script on the build server with a build agent / build definition with admin permissions?
推荐答案
您只需要确保您的构建服务帐户(可以是本地帐户、域帐户或工作组中的本地服务)也获得了管理员权限.
You just need to make sure your build service account (which can be a local account, a domain account, or Local Service in a workgroup) also got admin permission.
这篇关于TFS 构建:以管理员身份运行 Powershell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!