Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sudo on powershell on Windows

Tags:

Whenever I need to run a powershell script it complains of security, if I add powershell.exe -nologo -executionpolicy bypass -File .\install.ps1 I still get permission denied unauthorizedAccessException. I just want to run this install script, what is the sudo equivalent to type on the powershell on windows?

like image 366
eri0o Avatar asked Mar 23 '19 14:03

eri0o


People also ask

Does sudo work in Windows PowerShell?

Windows Powershell doesn't have sudo - some commands need to be run as an administrator and Powershell has no concept of that.

How do I run sudo on Windows?

There is no sudo command in Windows. The nearest equivalent is "run as administrator." You can do this using the runas command with an administrator trust-level, or by right-clicking the program in the UI and choosing "run as administrator." runas is elevation of a user account in Administrators; sudo is another thing.

Is there sudo for Windows?

gsudo is a sudo equivalent for Windows, with a similar user-experience as the original *nix sudo. It allows to run commands with elevated permissions, or to elevate the current shell, in the current console window or a new one. Just prepend gsudo (or the sudo alias) to your command and it will run elevated.

How do I get to root in PowerShell?

The Windows PowerShell prompt opens by default at the root of your user folder. Change to the root of C:\ by entering cd c:\ inside the Windows PowerShell prompt.


1 Answers

If you are using Chocolatey (a package manager), you can install a package named sudo.
Then you can use sudo like Linux 😋 sudo

like image 64
Sean Avatar answered Sep 28 '22 08:09

Sean