Still to this day I can't even fscking grep.
Still to this day I can't even fscking grep.
I have about the same problem when it comes to bash. While bash may very well be described as "arcane" I believe this is mostly a problem of unwillingness to learn something new or different.
Understanding how PowerShell works takes a bit of time and re-thinking. It doesn't help that there's so much downright bad PowerShell code out there that was mindlessly converted from VBScript. Still, it's not that hard and the language is quite consistent and, well, powerful. They made quite a large effort to make sure that the underlying concepts are orthogonal and pervasive throughout. So learning just a few concepts actually make a very large part of the shell and language approachable and easy to understand.
You're right in that Python may be a more apt comparison, especially in that PowerShell's .NET foundation serves as the equivalent to Python's included libraries.
But that's a discussion that would have to happen every time people try to think of PowerShell as a weird bash. And it is a capable and useful shell, too. It just can do a lot of things much better than bash; they just look different.
I guess what I always want to know when people complain about powershell is what they were actually trying to do. I think it's an excellent tool for system administration in a Microsoft environment. When you start moving away from that use case, it gets less and less useful.
perhaps if they were not too opposed early on to horrible open source things and just one of the languages that already fit fairly well in that area (python for example) they wouldn't have had to go out of their way to make pretty shitty hacks (i really wonder if anyone in the powershell\winrm team did any testing or development with the machines more than 10 metres away)
I don't think something like Python would have been a good choice to use instead of PS. While I'm sympathetic to the complaint that PS is more of a programming language than a shell, that's even more true of Python. I use PS as a shell far more often than I use it for complicated scripting, and as much as I like Python, I just can't see using it as a shell.
For your particular example:
> help grep
Name Category Module Synopsis
---- -------- ------ --------
Out-File Cmdlet Microsoft.PowerShell.U... Sends output to a file.
Select-String Cmdlet Microsoft.PowerShell.U... Finds text in strings and files.
Okay, so Select-String sounds really promising. Let's take a look. > help select-string
NAME
Select-String
SYNOPSIS
Finds text in strings and files.
SYNTAX
Select-String [-Pattern] <String[]> [-Path] <String[]> [-AllMatches] [-CaseSensitive] [-Context
[<Int32[]>]] [-Encoding {unicode | utf7 | utf8 | utf32 | ascii | bigendianunicode | default | oem}]
[-Exclude [<String[]>]] [-Include [<String[]>]] [-InformationAction {SilentlyContinue | Stop | Continue |
Inquire | Ignore | Suspend}] [-InformationVariable [<System.String>]] [-List] [-NotMatch] [-Quiet]
[-SimpleMatch] [<CommonParameters>]
Most of those command flags seem really straightfoward to me. Can you be more specific about what was unclear to you? I'd be happy to help.EDIT: BTW, it's a bit annoying to type Select-String, so it'd be nice if it had an alias. Does it have one?
Well, you can get aliases in PowerShell by typing alias. But that'll give you a wall of text; what you want to do is to quickly search for things that are aliased to Select-String.
There are two ways to do this. First, you can pipe to a GUI that allows directly filtering the results:
> alias | out-gridview
Or, alternatively, we can figure out what objects alias gives us: > alias | select -first 1 | get-member
Note that we've got a Definition field, and query on that: > alias | Where-Object { $_.definition -contains 'Select' }
which is a long version of > alias | ? { $_.definition -contains 'Select' }
And notice that Select-String is aliased to sls by default. Note that I can just reference the column by name, rather than going through some awk/cut fun.You might be annoyed that Select-String is not aliased to grep. While many commands actually do have multiple aliases to both DOS and Unix equivalents (e.g., Get-ChildItem is aliased to gci, dir, and ls, and Remove-Item has ri, rm, and del as aliases), Select-String works differently enough from grep that it's not a default alias so you're not confused.
They have had decades now to get on board with developers, and cmd.exe is still their go-to console. They still strike me as a company of greedy corporate business folk, who happen to run a software company, as opposed to a software company that has to suffer greedy corporate drones to survive in our current race to the bottom.
In fact most admin gui's are now just calling powershell now.
Correct - it has a couple of crippling features, such as wrapping output at 80 characters even if piped to a file (unless you tell it otherwise every time).