If you don't want PowerShell reporting your activities back to the mothership, don't forget to set<p><pre><code> POWERSHELL_TELEMETRY_OPTOUT=1
</code></pre>
in your environment before launching PowerShell!
I spent some time with Powershell on Windows recently, more time than I am used to. Powershell is a clear winner over CMD.EXE by a mile, but…<p>- As an interactive shell, it suffers from an ecosystem which is much poorer than the bash/zsh ecosystem,<p>- As a scripting language, I’m going to use Python or Go the moment anything becomes larger than a few lines,<p>- Installing Posh Git is just a really mediocre experience (indicative of various, more specific problems)<p>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.<p>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.<p>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.
Dude has more patience than me.<p>I tried running powershell on linux a few times, and every single time the second command I run is not supported on linux.<p>I don't even remember what the commands were, PSremoting was one for sure and I think another was Invoke-WebRequest.<p>Powershell on linux is a nice idea but in the current form it is in name only, as nearly nothing works.
Shameless plug: if you like the idea of processing structured data in a shell, you might also like Elvish (<a href="https://elv.sh/" rel="nofollow">https://elv.sh/</a>).
>For example, if we wanted to get the first three files from ls I’d do something like `ls | head -n 3`. In Powershell, it’s `$(dir)[0..2]` since the dir command is returning an array which I can index into.<p>You could do that, but the way to write it in the bash way would be `dir | select -first 3`<p>>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.<p>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<p><pre><code> $null | openssl s_client -showcerts -servername joejag.com -connect joejag.com:443 2>/dev/null | openssl x509 -inform pem -noout -text</code></pre>
While I really would like UNIX shells to get the ability to pass structured data, one problem is that most shells out AFAIK there don't give the ability to pass structured data natively.<p>For these structured shells(like Powershell, elvish, Nushell) to succeed, they should...<p>* have a spec on how to pass structured data from a native executable (without function calls like 'from-json')<p>* implement some structured data functionality in all GNU coreutils at the very least<p>* and push the 'structured shell evangelists' to implement these schemes on other programs.
The problem with powershell on Unix/Linux is that there is an implicit assumption everywhere that there is a shell available. If you look at simple git StackOverflow questions like "how do I get the oldest common ancestor commit for two branches", you'll happily see people answer with combinations of shell commands that assumes that there is a sh (or some times even bash or zsh!). Absolute madness that git can't do basic things without relying on external applications that may or may not exist.
I am dead serious. Powershell should replace (bash) shell scripting under any Linux.<p>I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead.<p>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.<p>Powershell even has a unit test tool called 'pester' which is funny to me because it means 'bully' in my native language.
Note that this article is slightly out-of-date. It looks like the experiment began in January with PowerShell 6, and there are notes about caveats that were scheduled to be fixed with PowerShell 7. PowerShell 7 has since been released.
"so they do these cool things, which of necessity break a model some of you will have been familiar with for 50 years in some cases, but its amazing"<p>(in my case, 40 years.)<p>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"
One of the missing ingredients in PowerShell when I tried to use it was network transparency - which I suspect will be hard to solve since it passes .net objects around.<p>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.<p>I also often save outputs rather than pipe, to inspect/debug, or avoid re-computation.<p>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).
I installed PowerShell on a Debian machine a while back so that I could use (VMware's) PowerCLI modules / commands.<p>That worked well enough -- exactly as on Windows, AFAICT -- but I can't imagine ever trying to replace my "daily shell" (<i>zsh</i>, in my case) with it.
I've been using Unix for 20+ years, switched to pwsh as my main shell 4 years ago (on both Windows and macOS).<p>Here's my notes: <a href="https://github.com/mikemaccana/powershell-profile/" rel="nofollow">https://github.com/mikemaccana/powershell-profile/</a><p>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.<p>nushell looks like one to watch too. It's a lot further behind than pwsh but has a faster growing community.
> For example, if we wanted to get the first three files from ls I’d do something like `ls | head -n 3`. In Powershell, it’s `$(dir)[0..2]` since the dir command is returning an array which I can index into.<p>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) <i>sorting</i> 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.
here is my opinion on `When X is going to replace bash?`<p>The story goes on like this:<p>You went to DataCentre, logged in to an internal machine, something happened (eg failure, diagnostic necessary et.al.) which you need to fix.<p>given condition, you don't have internet connection inside (air-gapped)<p>- You most likely have man-pages installed and having examples what to do in them,<p>- `--help` yields some sensible output<p>- Shell is 'fast', errors are well-known and defined.<p>Also, take into account of other comments that are discussing `how to do x` and why it doesn't/wouldn't work on PowerShell
On a related tangent, I think the Powershell project is the only place to get certain DotNet libraries that pertain to remote management. It's a bizarre situation.
> <i>and expect it to be possible when Powershell 7 comes out (I’m using Powershell 6 while writing this).</i><p>PowerShell 7 was released in early March a month and a half ago: <a href="https://github.com/powershell/powershell/releases" rel="nofollow">https://github.com/powershell/powershell/releases</a>