Cause TFS InvokeProcess Build Activity to run under other credentials

前端 未结 2 1419
爱一瞬间的悲伤
爱一瞬间的悲伤 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: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.

提交回复
热议问题