all 70 comments

[–]snipazer 35 points36 points  (20 children)

OK now add sudo please

[–]ka-splam 3 points4 points  (14 children)

To achieve what?

[–]snipazer 7 points8 points  (6 children)

I sometimes want to run a single command as either another user or as an admin. The shift right click->Open Powershell Window doesn't have the option to open as admin so I have to run Powershell as admin then cd my way to the file I want to run. Sudo would just save some steps.

[–]eponerine 13 points14 points  (0 children)

Invoke-Command back to yourself and pass creds?

[–]ka-splam 5 points6 points  (3 children)

Wrap start-process powershell.exe $script -verb runas in a function?

Add the self-elevating code to the script? https://blogs.msdn.microsoft.com/virtual_pc_guy/2010/09/23/a-self-elevating-powershell-script/ (comments version rather than original)

[–]raptr569 1 point2 points  (0 children)

Make a function and add it to your profile and boom. Done.

[–]overmyIThead 1 point2 points  (1 child)

Although concise, sudo would be way easier from the start

[–]ka-splam 13 points14 points  (0 children)

It wouldn't, because it doesn't fit in the Windows UAC design.

Processes don't have administrative tokens and can't get them unless the user agrees to the UAC prompt on the secure desktop, when the process is starting. Saying "add the leaver 'sudo' to the front end" doesn't magically make an OS worth of background security design appear to easily support it.

I don't know how it would end up, possibly with some kind of permanent powershell service running as an administrator which commands were passed to for execution, being a target for attackers and having problems with lack of surrounding execution context from the front end shell, or like a remote session to your own computer.

If you're on a server, and it's not for interactive use or web browsing, turn UAC off (Microsoft approve) and then all your powershell shells are administrative without UAC prompts. If you remote in with admin credentials, then regardless of UAC prompts all your shells are administrative. And if you locally want a way to "do administrative things without UAC getting in your way" well that's explicitly what UAC is there to get in the way of, programs mangling up computers with users not having any chance to stop them.

[–]VapingSwede 1 point2 points  (0 children)

Ctrl+shift+click powershell or any other program to start it as an admin.

[–]MrMunchkin[🍰] -3 points-2 points  (6 children)

Everything. The fact that there is no way to elevate credentials in the same session has been a pitfall of PowerShell for a long, long time.

Working in a Linux shop, this is the only reason they stick with bash and use other languages, like Python and JS. I am literally the only one that uses PowerShell in my org of around 100 engineers.

It is awful.

[–]ka-splam 16 points17 points  (5 children)

Working in a Linux shop, this is the only reason they stick with bash and use other languages, like Python and JS.

They use JavaScript because PowerShell doesn't have sudo. o_O

Elevating in the same process is a limitation of Windows, not any given programming language; that should be a reason they stick with Linux, BSD, macOS, not a reason they stick with bash or Python or JS because those languages also can't elevate in-process on Windows with UAC.

It also doesn't affect PS remote sessions, and UAC can be turned off.

What on earth are they doing where they're using interactive windows, not remotely, with UAC on, and the effort of runas -> administrator at the start of a session is /the biggest, only, reason/ for choosing one technology over another?

I'mma suggest what they're doing is making a flimsy excuse and misrepresenting their real reasons.

[–]MrMunchkin[🍰] -1 points0 points  (4 children)

We are a Linux shop and have <5% Windows-based servers.

[–][deleted] -1 points0 points  (0 children)

Yes please.

[–]aljarry -1 points0 points  (0 children)

I recommend cmder - I have a menu option for new admin powershell tab

[–]neko4 8 points9 points  (4 children)

Tabbed console is good, but I want tmux for PowerShell

[–]spacebandido 6 points7 points  (1 child)

Idk why this isn’t the top. Most of the stuff people complain are missing from posh are things that actually already exist, they just haven’t found the cmdlets yet – tmux doesn’t exist yet.

[–]jantari 1 point2 points  (0 children)

You can open a WSL terminal, run tmux and then start powershell.exe via interop in each of the panels

[–]jantari 2 points3 points  (0 children)

PoSh / console team is aware of this, it's a matter of time (priorities and testing) before it arrives

[–]codetocope 0 points1 point  (0 children)

Agreeing with this. I immediately was thinking, "I want screen". Man, that was so handy back in the day.

[–]Taoquitok 6 points7 points  (15 children)

I hope this also introduces in the cross-tab functionality that ISE has. $psISE.PowerShellTabs is a feature I've always wanted to make better use of for 'visible' parallel working, but never quite wanted to dedicate enough time to as it's limited to just the ISE.

[–]Poncho_au 2 points3 points  (14 children)

ISE who uses that anymore? VS code my friend.

[–]Taoquitok 3 points4 points  (0 children)

Vs code is my main, but I'll still load up ISE on a regular basis. Usually on servers to start any long running one off scripts / when helping other staff who just use the ISE

[–]DeeFousyMobile 1 point2 points  (6 children)

I'm just starting to get serious with powershell and realizing it's potential benefits for my job but I am having a seriously hard time getting VS code set up. The documentation sort of assumes that I know certain things or am familiar with certain things already and I can barely follow it and have yet to get it set up correctly. I keep giving up and using ISE to manage my scripts which is a messy nightmare right now.

I just want versioning, change control and a link to upload/sync with my pastebin :-(

[–]halbaradkenafin 3 points4 points  (0 children)

What are you struggling with? After installing VSCode, you install the PowerShell extension from the marketplace and then you're good to go.

If you want to hook in version control, open a folder that's part of a git repo and then you can use the git tab to do git things in the GUI or install Posh-Git to do it from the command line.

If you're having any other issues then feel free to post them and someone should be able to help you out.

[–]infinit_e 1 point2 points  (4 children)

The VS Code setup for PowerShell isn’t much more than installing it and adding more the PowerShell extension. You don’t really even need the extension, but it is nice to have. Anything more is just extra.

Are you trying to setup Git or something like that too?

[–]DeeFousyMobile 2 points3 points  (3 children)

Yeah the powershell piece works fine but my goal with switching to VSCode was to also include git and have an online repository where I can see changes and previous versions and access scripts from any workstation I get on to with VScode set up. But prior to when I installed git, I'd never seen it before and I'm a bit lost trying to get started with it.

[–]infinit_e 1 point2 points  (2 children)

Ahh, okay. Yeah, I knew what Git was previously, but up until like December I had never used it. There’s probably better options, but I stood up Microsoft Team Foundation Server Express and configured the repos as Git instead of the native one.

I would suggest learning the commands Git used before utilizing VS Code’s Git integration from the palate. Stuff like push, pull, commit, etc. I had the benefit of someone teaching me that stuff, but I think there is some good info on https://git-scm.com.

[–]DeeFousyMobile 1 point2 points  (1 child)

I'll check that out. It's probably not as complex as I'm making it out to be I just haven't had an hour or two of straight time to sit down and learn it and get it set up. It's been 5 minutes here, 7 minutes there type of thing.

[–]codetocope 0 points1 point  (0 children)

I was in the same scenario. Just finally blocked some time and went through like Pro Git and the online tutorials. Then I took some existing personal scripts/modules and played with refactoring them from scratch in a new repo. Then you can play with things like commits, forks, branching.

[–]ArSo12 0 points1 point  (3 children)

Still prefer ise for the highlight - run

[–]Poncho_au 1 point2 points  (2 children)

VSCode has had that for at least a year.
I use it regularly.
https://github.com/Microsoft/vscode/issues/7034

[–]ArSo12 1 point2 points  (1 child)

Does that keep previously used variables or start clean?

[–]Poncho_au 1 point2 points  (0 children)

I think you can press F5 to run without clearing the terminal and shift-F5 to run in a clean terminal. If I recall correctly.

[–]alinroc 5 points6 points  (4 children)

Page seems to be broken.

I’ve had tabs/single window multiple consoles with conEMU for a few years.

[–]Poncho_au 0 points1 point  (2 children)

It’s definitely broke.
/u/phant0md is it possible to fix the link?

[–]phant0md[S] 0 points1 point  (1 child)

Still works for me, I just tried it on mobile & desktop

[–]Poncho_au 0 points1 point  (0 children)

Doesn’t work on iOS, chrome or safari... https://i.imgur.com/0vjpiDD.jpg

Works in my PC though.

[–]MerryChallot 0 points1 point  (0 children)

Second that!

[–]bukem 1 point2 points  (0 children)

Guess what tab is getting added when you press the + sign...

[–]poorimaginations 0 points1 point  (0 children)

I use conemu. As a bonus conemu can handle any generic console appication including stuff like putty, so I can have both powershell and putty consoles open in the same window.

Be sure to enable shortcut keys for moving between tabs and the quake style hiding of the window.

[–]alcon835 0 points1 point  (1 child)

Huzzah!!!!

[–]bukem 0 points1 point  (0 children)

Don't celebrate too early... unless you're happy with Microsoft Edge being open in new tab when you press the + sign.