5 ms·
I've had to implement quite a bit of powershell scripting in my new job. I've always thought that their philosophy of "everything is an object" made sense, but
by geewee 7y ago
I've had to implement quite a bit of powershell scripting in my new job. I've always thought that their philosophy of "everything is an object" made sense, but looking at powershell scripts has always somehow made my skin crawl, probably because it's so different from years of ingrained bash scripting.
There's definitely a learning curve (and it's harder to find information online), but once you get used to it, it's actually a pretty pleasant, cross-platform scripting experience. I'd definitely say that I'm comfortable doing more advanced scripts in powershell than I ever was in bash. If I had to use anything more complex than a for-loop in bash, I would reach for a "proper" programming language - but I can do quite a bit more in powershell without having to switch.
- nimitz12 7y agoI agree that powershell scripting experience is better, but I've found powershell scripts to be very slow on Linux, that's why I am still using bash do you notice such an issue too?
- userbinator 7y agoI think the verboseness is a huge turn-off for beginners --- it's like a mix of C# and bash. The general prevalence of uppercase characters (I believe it's case-insensitive like a lot of Windows things, so I don't really understand why they had to capitalise words which are already hyphen-separated) also adds to the overall "clumsy" look. In contrast, bash scripting is basically entirely lowercase with very minor exceptions.
- vips7L 7y agoIt does come with a ton of aliases to shorten up the names. I do find pwsh commands to be much more memberable than bash because of the verboseness and full named flags/switches.
- Fr0styMatt88 7y agoI've become a massive fan of PowerShell. Getting used to using TAB-completion helps immensely, as do the aliases like you mentioned. For TAB-completion I use MenuComplete instead of the default (Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete) as it gives you IPython-like completion menus. With something like posh-git, it's amazing: you can type git checkout and then press TAB and have an interactive menu of the branches you can switch to; or if you've done a 'git status' you can then do git add, press TAB and you get a menu that intelligently shows you what files you might want to add.
- vips7L 7y agoThanks I'm going to check this out. The only thing I miss in pwsh is fish like suggestions when typing.
- mavhc 7y agoThat's pretty great. My problem with powershell is it's verb-noun, I want to tab complete on Network, not get-Network
- no_wizard 7y agoThanks for the pro tip! I just switched over to this and immediately noticed a huge improvement in my powershell experience :)
- OskarS 7y agoA notable thing about unix commands is that they're usually very short: "cd", "ls", "grep", "sed", "cat", etc. This is obviously a remnant of earlier times, but I actually think that it serves the unix command quite well even today. These are commands you want to type quickly and many right after another. Powershell's "Get-ChildItem" and "Select-String" are annoyingly verbose in comparison.
- shyn3 7y agoGet-ChildItem is gci. For Select-String I don't think there is a shorter version. Many of the commands have shorter aliases they are just not as intuitive. /r/PowerShell is really helpful if you are stuck also there is a Slack POSH group that is really helpful.
- vips7L 7y agoOn my W10 machine select-string was aliased to grep. Almost every command was already aliased. get-content -> cat set-location -> cd get-childitem -> ls etc
- jodrellblank 7y ago"sls" is select-string. Get-Alias to see them all. "get-alias -Definition Select-String" to look for one for a specific command.
- GordonS 7y agoI absolutely love C#, and I also really like bash. But powershell just looks so damned ugly to me! It's too verbose, and the idiomatic Pascal-Kebab-Case thing is just weird. I know powershell has aliases for common things, like `ls` or `wget`, but your scripts are no longer cross-platform if you use them, as you'll use the powershell functions on Windows, but the Linux commands on Linux. I've tried so hard to like it for so long, but I just... can't.
- 1337shadow 7y agoCan you compare UX with Xonsh ? https://xon.sh/ https://xon.sh/