TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Do you prefer Powershell?

8 点作者 nodra超过 2 年前
I’ve used it here and there throughout the years for small tasks and didn’t think much of it. The last 2 weeks, I’ve been using it more cause I have to do some work on a Windows VM and it’s nice! I’ll go back to bash after I’m done with this work cause that’s what everyone uses. I wouldn’t mind the switch though.<p>I know bash is the standard but does anyone opt for powershell even on a Linux vm?

7 条评论

richardjam73超过 2 年前
It works when it works but when it doesn&#x27;t it is a pain.<p>I recently was looking at doing some backup software in Powershell for Windows 10 and 11. My chosen method was to use a VHDX file (Windows backup does this). Now in powershell there are commands to create a VHD or VHDX file but they are tied to the Hyper-V package in Windows being installed. In Windows 11 this package has been totally removed and can no longer be downloaded or installed.<p>So next I tried to find another way to use VHDX files in Windows 11 from Powershell. So I discovered that the diskpart command line utility can create&#x2F;attach&#x2F;partition etc VHDX files. Diskpart however is not integrated into powershell. In order to use it you need to create a text file with the commands to run. Execute diskpart with that text file. Then you have to search the text output for the results.<p>At this point I felt like I should have been using a Unix shell anyway.
评论 #34451266 未加载
_ajoj超过 2 年前
I am having to learn it to write some scripts for a customer who insists on using Windows. It’s very neat. I’m especially impressed with the ability to create GUIs. [1]<p>Coming from bash the language is awkward. I would like to spend some time learning it more and running it on my main macOS machine.<p>[1] <a href="https:&#x2F;&#x2F;lazyadmin.nl&#x2F;powershell&#x2F;powershell-gui-howto-get-started&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lazyadmin.nl&#x2F;powershell&#x2F;powershell-gui-howto-get-sta...</a>
评论 #34449431 未加载
majkinetor超过 2 年前
I use pwsh on all platforms. All automation is done with it, and in many cases web app functionality depends on it running in background all the time (for large public services).<p>Even our GitLab runner uses pwsh.<p>To organizse build&#x2F;scripts we use Invoke-Build, a cross-platform task runner: <a href="https:&#x2F;&#x2F;github.com&#x2F;nightroman&#x2F;Invoke-Build">https:&#x2F;&#x2F;github.com&#x2F;nightroman&#x2F;Invoke-Build</a>
hiAndrewQuinn超过 2 年前
It&#x27;s pretty nice. I&#x27;ve made my small career so far out of being pretty at home in both *nix and Windows environments, and I prefer PoSH to bash mostly because it feels more like a really terse programming language than a shell. I also find that after I run it through `Edit-DTWBeautify` or the like, and all the aliases get deanonymized, it&#x27;s one of the easiest scripting languages for me to return to and understand just by reading it.<p>There is a bit of a painful paradigm shift, though, where you have to stop thinking in terms of text streams and more in terms of shuttling objects with properties around. It&#x27;s not a great idea to try to work with PowerShell exactly the same way you might construct a pipeline around `awk` and `grep`, because text streams just aren&#x27;t the real primitive in this environment. For that reason I think it usually makes sense to just a stick with whichever shell environment you grew up with, unless work or something forces your hand.
pragmatick超过 2 年前
Disclaimer: I&#x27;m inexperienced with bash and powershell.<p>I just converted a bash script to a powershell script. Some things are a lot easier (like writing errors or info messages in different colors). But I had a lot of problems getting the exit codes from maven calls to determine the exit result. Checking for 0 in shell works fine all the time, in powershell checking $LASTERRORCODE works sometimes but not always. I&#x27;m using try catch now but it&#x27;s a bit of a hassle (which is ironic, comic from a java developer).
评论 #34451100 未加载
fomine3超过 2 年前
I like it for scripting shell but not for daily interactive shell.
replwoacause超过 2 年前
I love it and use it almost every day.