Unable to run PowerShell modules that requires administrator privileges with sudo
AvogatoWizardWhisker opened this issue · comments
Sudo for Windows version
0.1.5
Windows build number
10.0.26063.1
Other Software
No response
Steps to reproduce
I wanted to run PowerShell modules like get-windowsupdate
with sudo
since it requires to be run in an elevated PowerShell console.
Expected Behavior
A UAC window will pop up and the command will run.
Actual Behavior
After launching sudo, it showed command not found
.
Are you running sudo
directly or via the sudo.ps1
script from this repository?
No, I'm not. Was i supposed to run it?
I am having the same issue, I am simply running sudo directly after enabling it directly in settings
For me I run sudo copy-item .\hosts .\hosts.old and get the same error of command not found
I've tried:
Copy-Item (with capital letters)
with -source and -destination
with absolute paths
Where sudo returns
C:\windows\system32\sudo.exe
I cant run anything with sudo, all come back with command not found
For the time being, and until Microsoft publishes how sudo and PowerShell integration works, I recommend you elevate PowerShell commands using the following syntax:
sudo pwsh { script }
If you want to use variables, you need to use sudo pwsh { Copy-item -source $args[0] -destination $args[1] } -args $src, $dst
Ye that worked except I typod when I said -source, its -path. It does work in that way for me. Hopefully op will test. Ill avoid until that is fixed tbh
thank you gerardog!
the root issue is not powershell specific. rather, it is
"Implement a feature | syntax to indicate sudo
that it should use the current shell(from which sudo
is invoked) to execute the commands".
this will solve both:
- running shell specific commands without specifying the current shell name.
For example: you will be able to run cmd
specifc commands directly without prefixing cmd
.
- nested shell specific commands.
For example: you could be running powershell specific commands in powershell which runs inside nushell which runs inside cmd and you won't have to prefix pwsh
.
/dup #5
Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!