- As an interactive shell, it suffers from an ecosystem which is much poorer than the bash/zsh ecosystem,
- As a scripting language, I’m going to use Python or Go the moment anything becomes larger than a few lines,
- Installing Posh Git is just a really mediocre experience (indicative of various, more specific problems)
Some of these things can be fixed up, like the bad experience installing Posh Git—you have to update the package manager to a non-release version, but the signature is occasionally broken (it seems to happen again and a gain) so you have to disable signature verification, and then you can use the updated package manager to download the Posh Git package.
Through the journey I encountered so many stupid random problems that it’s not something I can just step out and recommend to anyone. I’ll continue using it as my primary shell on Windows, but for various reasons (I forget the exact details) I had to give up on it for working with Git. There was a lot of “action at a distance”, like running ssh-agent would break the “ls” alias for Get-ChildItem, which leaves me high and dry without muscle memory.
Meanwhile, Microsoft is also spending time and money on WSL. Again, I’ll still be using PowerShell on Windows but even there it is a damn rough experience. The command-line has been paradoxically a second-class citizen as well as a necessary tool for development on Windows for as long as I can remember, and it will take a lot more improvement to PowerShell before that feeling disappears.
But maybe that's just a result if it being so new. 'ls' has been around for almost 50 years...
What it really feels like is a complete programming language inside of notepad.exe because of the historically terrible windows command prompt.
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineOption -ShowToolTips
Also note that you can get in-console help on most commands without having to go out to a web browser. On the ones I've tried, examples are also included which help output too.
Help will also list available commands; eg:
help json
Shows me the three commands available from my shell: ConvertFrom-Json, ConvertTo-Json and Test-Json.
There is also Get-Command, which you can filter for command discovery, ie:
Get-Command | where Name -Like "Json"
The advantage to PowerShell being object-based here is that if you press <TAB> after typing where, the list of completions you get will include the properties that are in the object returned as the result of Get-Command.
I also use Cmder for a much nicer console than cmd.exe. I haven't tried the latest version of the new Windows Terminal but I hear it's also nice.
This surprises me as I feel exactly the opposite.
I may not know how to manage X via PowerShell, but I know those pre-approved verbs like Get/Set/New/Test/Convert etc. Then I know commands from same module usually start with some abbreviation like Get-Net.... Then I can tab throguth commands.
Or just Get-Module (to see loaded/available modules) and then Get-Command -ModuleName x or just help tcp. And if "help Get-NetTCPSetting -Full" won't help, yeah, fallback to google.
Example. Now how would I set an IP address for an interface not having an idea? (where you see italicized, actually there are star-wildcard around the word)
1. help ip (ohh, too much results)
2. help set-ip - alright, Set-NetIPAddress
3. help Set-NetIPAddress -Examples (seems I need to specify some interface. It is probably at Get-NetIPInter<TAB> - ahh, gives me Get-NetIPInterface, here you are.)
4. Get-NetIPInterface
5. Set-NetIPInterface -<TAB><TAB><TAB> (autocompletes arguments and I choose which I would like to set or not)
It takes loads of reading and trial and error to become competent in any command line.
PS: the ISE (Integrated Scripting Environment) helps when writing scripts.
Even so, I don't think we can use that excuse given that it was released over 13 years ago...
I know all this is personal and subjective. I think using git to manage this is pretty easy and safe. If and when I want to update it’s as simple as doing a git pull in my local repo of posh-git and reloading the shell.
If the new version is broken (has never happened yet but ya know.. in case) just checkout the previous one.
I have found using git, the powershell user profile and modifying my user path when necessary is the best way of managing dev dependencies on Windows.
I also understand why people want this all abstracted away from them in a package manager.
* You have access to the entire .Net standard library
* Optional typing
* Writing functions and using pipes allows a functional style
* You can even inline some C# code, or read it from a separate file and compile it on the fly. I've used that to make windows API calls (P/Invoke).
Overall, I'd choose pwsh scripting over bash any day, and I'd say it doesn't even make me miss python all that much (for simple scripts, couple hundred lines max).The main feature lacking for larger scripts/tools is classes, I think. Unless it has changed in newer versions, powershell is object-oriented yet does not allow you to define custom classes, which is annoying to say the least. The workaround is loading c# on the fly.
The point is very much that with powershell this move is to C#, with a much nicer integration with the shell.
I always feel like things in power shell are harder then they need to be that other scripting languages I don’t have that problem. One thing I do like is being able to leverage .net locally and also import DLLs. That helps me get around a bunch of gaps.
I tried running powershell on linux a few times, and every single time the second command I run is not supported on linux.
I don't even remember what the commands were, PSremoting was one for sure and I think another was Invoke-WebRequest.
Powershell on linux is a nice idea but in the current form it is in name only, as nearly nothing works.
I would not invite it onto a *nix machine voluntarily where there are established patterns and solutions which have matured over the space of 40 odd years now.
In my experience with PowerShell on Windows, you have to approach it more like interactive python with shortcuts rather than a regular shell, and once you’re accustomed it works fine. The main issue is that it doesn’t work like a classic shell, it just has some affordances to look like a classic shell in common use cases.
If you want to do anything that would be windows only then you're right, it probably won't work.
That said, I usually have a tmux window ssh'd into a windows machine for powershell. It would be nice to be able to manage ad and exchange from a linux machine with powershell.
Being able to do simple web scraping like this in a "shell" is pretty great:
$hn = Invoke-WebRequest https://news.ycombinator.com/
$hn.AllElements | Where {$_.TagName -eq "a" } | Where { $_.Class -eq "StoryLink" } | select "innerHtml"So is creating secure strings.
Cool!
Powershell is a nice idea, but Microsoft is kidding themselves if they think it's even close to the alternatives.
I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead.
Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice.
Powershell even has a unit test tool called 'pester' which is funny to me because it means 'bully' in my native language.
I don't get the hate on Bash though. It's a natural extension of the command line, and works quite nicely to get a lot done without the overhead. Deployment is a lot easier in my environment (web hosting) because all of the servers are homogenous, and I don't need to worry about any dependencies because I rely mostly on coreutils + grep and awk.
Dutch?
If you're arguing that powershell should be the default that's a different argument. sh syntax is still in widespread use because of how portable it is and how widely known it is. It truly is the lingua franca of unixey OSes.
If you have to write shell scripts on Linux then target #!/bin/sh and write it so that it works in other shells.
The problem with Powershell for scripting is that it is just good enough that people don't go use something better like Python or Ruby.
Bash is weird, but it is everywhere and it's simple, and that simplicity is going the be very difficult to replace. How do replace nothing?
I love Python, do switch to it.
( The windows and MS stack is utter balls )
I wouldn't call it over-engineered. Ambitious? Maybe, but I don't see PowerShell lagging behind in any front it's designed for.
I really couldn't agree less. Title-Case with hyphens and verbose command names make it horrible just to type. The only reason I see for doing that is so that it would fit in with the rest of the ecosystem.
Maybe it's a nice scripting language: we already have quite a lot of nice scripting languages.
This probably means you don't have a CS background and/or very little experience with linux/scripting/etc and dare I say powershell itself. Scripting in linux/unix/etc is primarily text based whereas powershell is object based ( which is why powershell tends to be slow in comparison ). Also, the only thing going for powershell is it's tie-in with the .Net Framework along with Microsoft based servers ( such as SQL Server ). Like most Microsoft products, it's meant for their environment. There really isn't any real reason for powershell on linux.
> I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead. Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice.
Sounds about right. I can't believe that's what you wrote in support of powershell. Linux, bash, etc was built from the ground up to be command-line friendly. Windows was built to be GUI friendly. But there is a reason why windows administration is viewed as a joke in the tech industry. I guess powershell may seems amazing when going from GUI based administration to actual script based automation/administration.
> Powershell even has a unit test tool called 'pester' which is funny to me because it means 'bully' in my native language.
Yeah, it means bother/annoy in english, but you probably knew that already.
POWERSHELL_TELEMETRY_OPTOUT=1
in your environment before launching PowerShell! export POWERSHELL_TELEMETRY_OPTOUT=1
and, in theory, you should be good to go (unless/until Microsoft decides to change things up).---
After logging out and logging in again, you can verify this has been set properly by simply running
echo $POWERSHELL_TELEMETRY_OPTOUT
in your shell (it should simply output "1").You could do that, but the way to write it in the bash way would be `dir | select -first 3`
>a quick Google told me to use `echo | openssl s_client -showcerts -servername joejag.com -connect joejag.com:443 2>/dev/null | openssl x509 -inform pem -noout -text` which works fine in Bash or Zsh. Still, in Powershell, it throws an error for some reason.
It won't throw an error (unless you're running it without a tty), but it will ask you to enter the parameter of `echo`. That's because `echo` aka `Write-Object`'s parameter is required, unlike bash's `echo`. `echo |` in bash is the same as `< /dev/null`, but that also doesn't work in pwsh because it doesn't support `<`. The pwsh way is to pipe `$null`, thus
$null | openssl s_client -showcerts -servername joejag.com -connect joejag.com:443 2>/dev/null | openssl x509 -inform pem -noout -textI would have said "ls | head -n3" as well. I've never heard of "select". I just tried your suggestion and it doesn't appear to work:
$ dir | select -first 3
bash: syntax error near unexpected token `3'Fyi, `dir | select -first 3` also works in PowerShell.
Here's my notes: https://github.com/mikemaccana/powershell-profile/
Last few weeks I've been going back to bash, mainly to try out WSL/Ubuntu's defaults, but will probably move to pwsh there too. I like the consistent naming (which means I can guess commands) and avoiding the scraping that's inherent in text-only shells.
nushell looks like one to watch too. It's a lot further behind than pwsh but has a faster growing community.
For example in my PS (unsure who created aliases because I think some aren't default) I have both "ls" and "dir" for "Get-Childitem", "wget" for "Invoke-Webrequest" and so on.
https://devblogs.microsoft.com/powershell/introducing-consol...
For these structured shells(like Powershell, elvish, Nushell) to succeed, they should...
* have a spec on how to pass structured data from a native executable (without function calls like 'from-json')
* implement some structured data functionality in all GNU coreutils at the very least
* and push the 'structured shell evangelists' to implement these schemes on other programs.
> For these structured shells(like Powershell, elvish, Nushell) to succeed, they should...
For PowerShell to succeed, Microsoft should rewrite all the GNU coreutils? Did you see the months of outcry when Microsoft used the four characters "curl" in PowerShell? You reckon anyone is going to want unilaterally rewritten coreutils? From Microsoft?
Microsoft should stop on their development of a completely new tool and hobble themselves to the constraints of the stuff they're trying to replace, controlled by people they're in competition with? Unlikely fantasy world.
> That is unlikely to happen in PowerShell because the structured data is .Net objects.
Isn't that an implementation detail?
> You aren't going to do that from a native command running in a separate process returning data through stdout without serializing it - and then you're back to convertfrom-json as far as it matters.
Not having to write 'convertfrom-json' IMHO is a big improvement. 'ls[0..3]' is much more convenient than 'ls | from-json[0..3]'. (Imaginary syntax, BTW.)
> For PowerShell to succeed, Microsoft should rewrite all the GNU coreutils?
I wasn't really talking about PowerShell either, but well, yes I do think that for PowerShell to succeed there should be support for native PowerShell in 'ls', 'find', 'grep', etc...
> You reckon anyone is going to want unilaterally rewritten coreutils? From Microsoft?
It doesn't to be 'rewritten', it just have to gain support. I don't think that a set of patches that adds a new output format will be that problematic. And, one doesn't have to use PowerShell support if one isn't using PowerShell.
> Microsoft should stop on their development of a completely new tool and hobble themselves to the constraints of the stuff they're trying to replace, controlled by people they're in competition with? Unlikely fantasy world.
Er... you know - nobody said that one should replace your bash with Powershell. If you decide that the 30-year-old-unable-to-handle-spaces-in-filenames-by-default script language is fine for you, then you can keep using bash. They're not EEEing...
BTW, checkout elvish shell, since it's not from MS and it has some good ideas. You might like it if you're just hating PowerShell b.c. it's from Microsoft.
Since most developers use windows, most windows users use cmd as their shell and git is the most common vcs around, it wouldn’t surprise me if the most common environment for git is ... Windows cmd. Where there is no sed/grep/awk etc!
(in my case, 40 years.)
There is considerable merit in new things. But there are also costs. And, there is the proplist version of this story in OSX. So, I know this is a "thing"
Hmm, yes, but it's not a lazy array/list, so it's not online, is it. If you have a few million files in a directory, that's not going to work. To be fair, neither is `ls | head -n3` -- you have to use `ls -f | ...` to avoid ls(1) sorting the listing first, but if you do, this will be online. For ls(1) it's not really an issue, but in general you want your shell to be online.
It is lazy. The author slightly misunderstood / oversimplified what's going on. The commandlet does not build an entire array in memory and then write it out; it writes out each item one at a time. Evaluating it as `$(dir)` just forces all its output to be collected into a single value, ie an array. It's the equivalent of writing `output="$(ls)"; <<< $output head -n3` in bash.
I posted an alternative way to write this in https://news.ycombinator.com/item?id=22963842 which does not need to build the output as an array first and is also more natural to write.
The story goes on like this:
You went to DataCentre, logged in to an internal machine, something happened (eg failure, diagnostic necessary et.al.) which you need to fix.
given condition, you don't have internet connection inside (air-gapped)
- You most likely have man-pages installed and having examples what to do in them,
- `--help` yields some sensible output
- Shell is 'fast', errors are well-known and defined.
Also, take into account of other comments that are discussing `how to do x` and why it doesn't/wouldn't work on PowerShell
Bash also has not replaced all other UNIX shells.
It is not often that I pipe things into or out off ssh, a Unix domain socket or a pipe, but when I do it’s usually significantly easier and more efficient than other ways.
I also often save outputs rather than pipe, to inspect/debug, or avoid re-computation.
I last played with PowerShell on Win7 ages ago so things might have improved dramatically (e.g. if every output is guaranteed to round trip serialize with a network stream).
That worked well enough -- exactly as on Windows, AFAICT -- but I can't imagine ever trying to replace my "daily shell" (zsh, in my case) with it.
PowerShell 7 was released in early March a month and a half ago: https://github.com/powershell/powershell/releases