I'm loving the new Ubuntu builds - I'm also loving that powershell comes on the build already!
I'd love an option to start powershell with sudo on linux.
For example, lets say myscript.ps1 requires su permissions for something (running Install-Module without -Scope CurrentUser is a real example:
- ps: myscript.ps1
the myscript.ps1 is run in a non-sudo'd pwsh process and so it fails. The only way to run a sudo'd powershell command is to have a line that does something like this:
- sh: sudo pwsh myscript.ps1
That's a good workaround, although that does have a problem that it creates a new runspace every time.
That said, it's possibly a year out. Plus there's still utility in a pwsh launched with sudo even when this feature comes out so you don't have to special case your scripts with:
I'm loving the new Ubuntu builds - I'm also loving that powershell comes on the build already!
I'd love an option to start powershell with sudo on linux.
For example, lets say
myscript.ps1
requires su permissions for something (runningInstall-Module
without-Scope CurrentUser
is a real example:- ps: myscript.ps1
the
myscript.ps1
is run in a non-sudo'd pwsh process and so it fails. The only way to run a sudo'd powershell command is to have a line that does something like this:- sh: sudo pwsh myscript.ps1
That's a good workaround, although that does have a problem that it creates a new runspace every time.
That is to say, I can't:
And the scripts will be executed in the same runspace.
There should be a flag that allows pwsh to be run with sudo so that:
run in the same runspace with su permissions.
Note: PowerShell is working on supporting sudo at the cmdlet level:
sudo Install-Module foo
https://github.com/PowerShell/PowerShell/issues/3232
That said, it's possibly a year out. Plus there's still utility in a pwsh launched with sudo even when this feature comes out so you don't have to special case your scripts with: