TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Two Months with Powershell on a Unix

142 pointsby joejagabout 5 years ago

18 comments

jlgaddisabout 5 years ago
If you don&#x27;t want PowerShell reporting your activities back to the mothership, don&#x27;t forget to set<p><pre><code> POWERSHELL_TELEMETRY_OPTOUT=1 </code></pre> in your environment before launching PowerShell!
评论 #22965780 未加载
评论 #22964279 未加载
评论 #22963465 未加载
评论 #22964955 未加载
评论 #22967306 未加载
klodolphabout 5 years ago
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&#x2F;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.
评论 #22964733 未加载
评论 #22964856 未加载
评论 #22967374 未加载
评论 #22967673 未加载
评论 #22966426 未加载
评论 #22964655 未加载
评论 #22967364 未加载
dijitabout 5 years ago
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&#x27;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.
评论 #22962485 未加载
评论 #22962423 未加载
评论 #22962467 未加载
评论 #22967402 未加载
评论 #22963208 未加载
xiaqabout 5 years ago
Shameless plug: if you like the idea of processing structured data in a shell, you might also like Elvish (<a href="https:&#x2F;&#x2F;elv.sh&#x2F;" rel="nofollow">https:&#x2F;&#x2F;elv.sh&#x2F;</a>).
评论 #22964431 未加载
Arnavionabout 5 years ago
&gt;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>&gt;a quick Google told me to use `echo | openssl s_client -showcerts -servername joejag.com -connect joejag.com:443 2&gt;&#x2F;dev&#x2F;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&#x27;t throw an error (unless you&#x27;re running it without a tty), but it will ask you to enter the parameter of `echo`. That&#x27;s because `echo` aka `Write-Object`&#x27;s parameter is required, unlike bash&#x27;s `echo`. `echo |` in bash is the same as `&lt; &#x2F;dev&#x2F;null`, but that also doesn&#x27;t work in pwsh because it doesn&#x27;t support `&lt;`. The pwsh way is to pipe `$null`, thus<p><pre><code> $null | openssl s_client -showcerts -servername joejag.com -connect joejag.com:443 2&gt;&#x2F;dev&#x2F;null | openssl x509 -inform pem -noout -text</code></pre>
评论 #22965596 未加载
评论 #22964125 未加载
评论 #22964807 未加载
评论 #22964830 未加载
pcr910303about 5 years ago
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&#x27;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 &#x27;from-json&#x27;)<p>* implement some structured data functionality in all GNU coreutils at the very least<p>* and push the &#x27;structured shell evangelists&#x27; to implement these schemes on other programs.
评论 #22963665 未加载
alkonautabout 5 years ago
The problem with powershell on Unix&#x2F;Linux is that there is an implicit assumption everywhere that there is a shell available. If you look at simple git StackOverflow questions like &quot;how do I get the oldest common ancestor commit for two branches&quot;, you&#x27;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&#x27;t do basic things without relying on external applications that may or may not exist.
评论 #22966171 未加载
louwrentiusabout 5 years ago
I am dead serious. Powershell should replace (bash) shell scripting under any Linux.<p>I find shell scripts terrible, I&#x27;ve learned to switch to Python quickly, despite the overhead.<p>Powershell is very command-line friendly, with easy tab-completion of commands. I&#x27;ve worked with it extensively on Windows, creating large worklflows with it, it&#x27;s very nice.<p>Powershell even has a unit test tool called &#x27;pester&#x27; which is funny to me because it means &#x27;bully&#x27; in my native language.
评论 #22963470 未加载
评论 #22963755 未加载
评论 #22965269 未加载
评论 #22965102 未加载
评论 #22963819 未加载
评论 #22967782 未加载
评论 #22963709 未加载
zenexerabout 5 years ago
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.
ggmabout 5 years ago
&quot;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&quot;<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 &quot;thing&quot;
评论 #22965431 未加载
beagle3about 5 years ago
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&#x2F;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).
jlgaddisabout 5 years ago
I installed PowerShell on a Debian machine a while back so that I could use (VMware&#x27;s) PowerCLI modules &#x2F; commands.<p>That worked well enough -- exactly as on Windows, AFAICT -- but I can&#x27;t imagine ever trying to replace my &quot;daily shell&quot; (<i>zsh</i>, in my case) with it.
nailerabout 5 years ago
I&#x27;ve been using Unix for 20+ years, switched to pwsh as my main shell 4 years ago (on both Windows and macOS).<p>Here&#x27;s my notes: <a href="https:&#x2F;&#x2F;github.com&#x2F;mikemaccana&#x2F;powershell-profile&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mikemaccana&#x2F;powershell-profile&#x2F;</a><p>Last few weeks I&#x27;ve been going back to bash, mainly to try out WSL&#x2F;Ubuntu&#x27;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&#x27;s inherent in text-only shells.<p>nushell looks like one to watch too. It&#x27;s a lot further behind than pwsh but has a faster growing community.
评论 #22963471 未加载
评论 #22963911 未加载
cryptonectorabout 5 years ago
&gt; 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&#x27;s not a lazy array&#x2F;list, so it&#x27;s not online, is it. If you have a few million files in a directory, that&#x27;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&#x27;s not really an issue, but in general you want your shell to be online.
评论 #22964537 未加载
评论 #22964571 未加载
pvtmertabout 5 years ago
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&#x27;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 &#x27;fast&#x27;, 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&#x27;t&#x2F;wouldn&#x27;t work on PowerShell
评论 #22966102 未加载
Rapzidabout 5 years ago
On a related tangent, I think the Powershell project is the only place to get certain DotNet libraries that pertain to remote management. It&#x27;s a bizarre situation.
jodrellblankabout 5 years ago
&gt; <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:&#x2F;&#x2F;github.com&#x2F;powershell&#x2F;powershell&#x2F;releases" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;powershell&#x2F;powershell&#x2F;releases</a>
0x8BADF00Dabout 5 years ago
I like that it passes objects instead of strings, I could see that being really useful. Get-Member will list all methods and properties of an object.
评论 #22965071 未加载
评论 #22964200 未加载
评论 #22963952 未加载