4 ms·
If you're at the command line anyway, Powershell is nearly always a better choice, and it has that covered also. See TokenDiversity 's comment, or use a simple
by stinos 9y ago
If you're at the command line anyway, Powershell is nearly always a better choice, and it has that covered also. See TokenDiversity 's comment, or use a simple function or use Invoke-Elevated from an installable package. E.g. https://stackoverflow.com/questions/1566969/showing-the-uac-prompt-in-powershell-if-the-action-requires-elevation https://stackoverflow.com/questions/1566969/showing-the-uac-...
Or if you know the admin account you could use something like
Invoke-Command -ScriptBlock { ls } -ComputerName $env:COMPUTERNAME -Credential (Get-Credential)
- jhasse 9y ago> Powershell is nearly always a better choice Not if I want resemblance with Bash-like shells. I guess that's also the point of this: Most people already know sudo from Linux and cmd.exe, now they can use both together.
- nailer 9y ago20 year bash user and recent Powershell convert here. Powershell has proper things like profiles and aliases, cool stuff like being able to cd and rm the Environment and Registry keys like files. cmd has none of those. (Plus powershells structured output so you can use 'where' and 'select' and 'get-member' rather than scraping with regexs. )
- posguy 9y agoBut why saddle myself with a registry? I just don't see the need. Also, basic stuff like tab completion and so forth just doesn't exist in Powershell, copying/pasting is a nightmare, and it has its own syntax tomfoolrey like opening Internet Exploder when I just wanna download a damn file via CLI! It isn't that hard to build a decent shell, if zsh can do it, why can't MS put a few decent interns on it and get their act together? I feel like I'm knocking skulls together whenever I end up talking Powershell with someone from across the lake here in Seattle, this stuff isn't all that difficult!
- holydude 9y agoBecause you are just used to the way how bash/zsh works and Powershell is superior to any of the shells mentioned. I am a "recent" powershell convert (started 1y ago) and this different paradigm feels now more natural than traditional text parsing.
- posguy 9y agoWow, way to completely ignore the question. Saying "its better" without even responding to the glaring unresolved errors by MS I highlighted is totally pointless. Your comment successfully added nothing of value to this HN thread, besides showing your lack of ability to string together a coherent and logical reply, good jerb!
- holydude 9y agoQuiet the contrary to be honest. Calling MS tech names and dismissing the great work of those that created PS is just a sign of immaturity or simply an OSS zealotry. Your bashing of PS either comes from ignorance or you simply did not invest enough time to learn the technology. Tab completion and copy/pasting works flawlessly in powershell..you can even pipe to clip and have it in your clipboard. Downloading a damn file from internet is one of the simplest things you can do in PowerShell (and imho more pleasant than gluing wget/curl in your scripts). Bashing the syntax is totally unfair as it's a different paradigm.
- posguy 9y agoI tried approximately a year ago to figure out Powershell, other people in this thread have said "Oh, install all these things to clean it up, here are only a handful of them, have fun" which is pretty useless. I don't want to have to spend my time installing a bunch of crap on each Windows box I touch, it either has sane defaults and is usable from the get go, or I'm polishing a turd.
- nailer 9y ago
- kelnos 9y ago> cool stuff like being able to cd and rm the Environment and Registry keys like files. cmd has none of those Emblematic of what's wrong with the Powershell (or perhaps MS as a whole) philosophy: you don't build this functionality into a shell, you build a file system module (you'd do it with FUSE if on Linux) that "mounts" the registry as a bunch of files. Then you could edit it in any shell or text editor, or even in a GUI file manager and GUI text editor if you wanted to.
- duke360 9y agoi would call it "what's right with powershell" instead
- cptn_brittish 9y agoBy adding extra complexity to a shell command instead of offloading the process to small programs with a defined api? I can see a lot more maintainability and portability of a implementation using FUSE to mount these systems as filesystems (so the abstraction is complete across the entire system instead of just in the command). Also the ease of having a abstraction which does not require special capabilities to be added to a program before it is useful is a reason that no system has properly supported these models before in this manner. On a UNIX system the same techniques could of been implemented sometime between the 70's and now to interact with environment variables and it has probably been implemented before but it has not gained mindshare as that approach is not scalable.
- nailer 9y agoYou know bash has /dev/tcp right? Not saying either is OK, just that they both do this.
- stinos 9y agoYou can hardly call cmd.exe a candidate for Bash resemblance. If you want that you should be looking at cygwin and the likes.
- jhasse 9y agoIt's good enough for the few times I use Windows. For example stuff like make && ./output works. Git works from it. Also with clink (https://mridgers.github.io/clink/ https://mridgers.github.io/clink/ ) it becomes even more similar. But you're right: For the times where you need more, you should fire up MSYS2 for example.