Cause TFS InvokeProcess Build Activity to run under other credentials

前端 未结 2 1420
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 21:21

We have customized the build process with a InvokeProcess action that runs a powershell script that deploys our sln.

Problem is that this script must be run under a

相关标签:
2条回答
  • 2021-01-14 21:41

    I have created a blog post on this how you can achieve this: Customize Team Build 2010 – Part 9: Impersonate activities (run under other credentials)

    0 讨论(0)
  • 2021-01-14 21:43

    A pure PowerShell option, assuming you have PowerShell 2.0 on your TeamBuild machine, is to use a background job. Start-Job allows you to specify the credentials of another account to perform the work. After spinning up the background job in your script you will probably want to wait for the job to finish and grab the results to output from the main script e.g.:

    $cred = Get-Credential
    $job = Start-Job -ScriptBlock { ls c:\windows\system32 -r *.sys } -Cred $cred
    Wait-Job $job
    Receive-Job $job
    

    With respect to capturing, storing and retrieving the credentials, see this blog post for a good treatise on the subject.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题