Windows Powershell doesn't have sudo
- some commands needs to be run as an administrator Powershell has no concept of it.
One solution we can use is Start-Process
command: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/start-process The following line is the example of this command.
Start-Process wpr -verb runAs -Args "-start GeneralProfile"
This is calling wpr
(Windows Performance Recorder) as an administrator and passing necessary arguments with -Args
flag. However in this case, the challenge is that we don't see the output because theoretically, since it starts a new shell somewhere.
The other way you can think is scoop (https://scoop.sh/) which enables the commands equivalent to the one in Linux. You can install by following way:
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
set-executionpolicy unrestricted -s cu -f
scoop install sudo
By installing this, you can use sudo
just like you're in Linux. However with this, it's basically doing the same thing with the above so it's not possible to see the output anyway. (You can see the script inside here: https://github.com/lukesampson/psutils/blob/master/sudo.ps1)
Comments
Article is closed for comments.