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 Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 30,376 Reputation points Microsoft Vendor
    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