Powershell run command as admin

Filip 831 Reputation points
2021-04-18T20:17:37.113+00:00

Hello.
Im have open shell without admin privilegi and i want run some comand which require admin privilegi.
Is there way how to run this command without open new shell as admin?
For example "sudo" in linux (if you know)
Thanks for answare.

Windows for business Windows Server User experience PowerShell
{count} votes

Accepted answer
  1. Anonymous
    2021-04-19T01:40:59.083+00:00

    Hi,

    You can use the "-Credential" parameter to specify the admin account for some cmdlets like "Install-Module". For those without the "-Credential" parameter you can
    start another PowerShell process as administrator

    Start-Process -FilePath "powershell" -Verb RunAs  
    

    https://learn.microsoft.com/zh-cn/powershell/module/Microsoft.PowerShell.Management/Start-Process

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.