0

I have a problem with making custom task for Azure Devops: I need to run a PowerShell script with admin permissions when task.json calls PowerShell

"execution": {
    "PowerShell3": {
        "target": "$(currentDirectory)\\X.ps1",
        "workingDirectory": "$(currentDirectory)"
                   }
              }      

In the above code, how can I define that PowerShell can be run with the access of the administrator?

0

1 Answer 1

1

how can I define that PowerShell can be run with the access of the administrator?

I am afraid there is no such feature to run the PowerShell with the access of the administrator.

That because that When you execute the build, all build tasks should run under your build service account such as NetworkService. If you run the PowerShell scripts in the extension task. It's not able to directly run the script as a different user.

Besides, the extension task will be installed on different Azure devops and executed with different agents, we could not set a fixed account as an administrator account to apply to all different agents. What`s more. If we could use the extension task to run the PowerShell as admin, then we can apply it to do many things that exceed the authority, such as changing the password and so on. Obviously this is unsafe.

Sign up to request clarification or add additional context in comments.

3 Comments

I think there must be a way. For example: Task PowerShell, which we can tell it to run a PowerShell file with admin access.
@Arm-m, Yes, we could run a powershell file with admin access, but that need we run the powershell in the local agent and 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.stackoverflow.com/questions/38458899/…. But, in your case, you call the powershell file in the extension, how could we set our build service account as admin in other machine? So, I am afraid there is no such feature, if you get the solution, you could share it here.
@Arm-m, Any update for this issue? Have you resolved this issue? If not, would you please let me know the latest information about this issue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.