I am trying to create RamDisk in DevOps agent servers using PowerShell task from Pipeline. The script can create the Ramdisk rive but unable to format and mount it. Its giving error that it needs elevated prompt. How I can run PowerShell task with admin privileges in Azure DevOps pipeline
Asked
Active
Viewed 4,880 times
9
-
Is my reply helpful? Is your issue solved? – Cece Dong - MSFT Nov 13 '20 at 09:56
-
Any update and find solution for doing this? – sorosh_sabz May 07 '21 at 15:06
2 Answers
1
Since you add azure-devops-self-hosted-agent
tag, I assume you are using a self-hosted build agent for build. Then you can try to update the build agent to run with an administrator account.
If you configured the agent to run as a service, it starts automatically. You can view and control the agent running status from the services snap-in. Run
services.msc
and look for the agent. If you need to change the agent's logon account, don't do it from the Services snap-in. Instead, try to re-configure the agent and run it with an administrator account.

Cece Dong - MSFT
- 29,631
- 1
- 24
- 39
-
4This does not work, the agent runs using an Administrator account however it does not run the commands in an elevated terminal, resulting in an access denied error anyways. – alessandrocb Jan 28 '21 at 02:19
-
How to run command with elevated terminal? I think it is irrelevant from service user, it is about running elevated terminal without any popup and silently. – sorosh_sabz May 07 '21 at 15:06
-
I've not found a way to achieve this for exactly the reason that @alessandrocb mentions . Instead we will be trying to use the RunAs module to install modules as CurrentUser mode for all the accounts that we need them in. This way you can automate the install with ADO pipeines. Otherwise you are back to installing / upgrading by hand which is not my idea of fun. – Brett Jan 20 '23 at 21:43
1
- I have created Service Account with full admin privileges on my self-hosted agent
- I have added the self-hosted agent to the Azure DevOps pool and configured it using this Service Account
- All my tasks are running with admin privileges
My suggestion would be to configure the self-hosted agent using your Administration Account

vinilka8
- 21
- 6