Hacker News new | ask | show | jobs
by Nerada 3205 days ago
>I have written few ps scripts and virtually every line, every step, every task almost always required googling.

In what way? I use PowerShell daily and hardly ever have to Google [things that I've used more than once]. I imagine if I picked up another language, I'd be Googling furiously, but that shouldn't disqualify the language.

1 comments

I find this hard to believe unless your use is limited to "dir this" and "ping that".

Powershell is like a gas station men's room in the middle of nowhere. It's better than nothing but nothing to celebrate.

>I find this hard to believe unless your use is limited to "dir this" and "ping that".

as opposed to bash/posix with its confusingly named utilities?

    want to rename something? it's mv
    want to tell the time? it's date
    why is the command to download something curl/wget?
    what's the difference between if [[ stuff ]] and if [ stuff ] anyways?
the list goes on. and no, man pages don't help if you don't even know which command to look for. at least powershell has a somewhat consistent naming convention for its commands (verb-something) so you can at least sort of guess what the command is.
> want to rename something? it's mv

There is a rename command as well. But apart from the first time I tried to rename a file I've never had trouble remembering it. There is a good reason for it to, internally it is a move operation.

> want to tell the time? it's date

Is this different in powershell? Some quick googling indicates the Get-Date is the method you want and being .net based everything deals with DateTime objects.

> why is the command to download something curl/wget?

I find this easier to remember than Invoke-WebRequest, or is it Invoke-RestMethod?

If they were so hard to remember that could be aliased to something similar, but I've never seen anyone bother.

Edit - I mean I've never heard anyone going the other way and suggest doing "alias Invoke-WebRequest=\"curl\"" in bash.

They're pre-aliased to curl and get. ls works too. Most of the options won't work of course.
> why is the command to download something curl/wget?

I find this easier to remember than Invoke-WebRequest, or is it Invoke-RestMethod?

easier to remember: maybe, but much less discoverable than Invoke-WebRequest/Invoke-RestMethod. this seems to be the overall trend for linux shell commands. a few characters long for easy typing, but otherwise arbitrary strings that you have to remember and have 0 discoverability. GGP's comment was about how you had to search for how to do everything in powershell, so in that respect powershell is at least not worse than bash.

> 0 discoverability

Have you ever heard of `apropos`?

Interesting ....

I really liked DEC's VMS DCL ... and "help" was top notch.

want to rename something? it's Rename-Item, unless you also want to put it somewhere else, in which case you need Move-Item (it won't figure it out for you.)

want to tell the time? it's Get-Date ("time" won't work, neither will "get-time")

why is the command to download something Invoke-WebRequest?

what does '&"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:about' do?

and if you want to complain about ridiculous syntax, why the hell is ` the escape character instead of \ like every other language?

>want to rename something? it's Rename-Item, unless you also want to put it somewhere else, in which case you need Move-Item (it won't figure it out for you.)

so... working as intended? (unless you subscribe to the belief that rename is the same operation as moving)

>want to tell the time? it's Get-Date ("time" won't work, neither will "get-time")

fair point, although at least it doesn't alias any existing commands (typing time will get you a confusing output of 0 user, 0 kernel, 0 real)

>what does '&"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:about' do?

& = run program in specified path. i agree this isn't used in any other shell language, but then again all the linux shells are fairly similar to start with. it's probably there because otherwise it won't be able to differentiate between a command that you want to execute, and a string literal.

also for windows command line programs, it's fairly stander to use /arg:value for command line arguments instead of --arg value

>and if you want to complain about ridiculous syntax, why the hell is ` the escape character instead of \ like every other language?

probably because \ is used in windows paths, so to avoid unnecessarily quoting every path, they chose an odd line continuation character.

also, about what you were responding to for the last two points: that was more a poke at how '[' isn't actually part of the syntax, but in fact an alias for test.

> probably because \ is used in windows paths,

Or.. you could actually encourage people to use sane path separators. The rest of the world uses a normal slash which works most of the time in Windows too.

CP/M lost. URLs won.

It's like UTF-16. They somehow had the means to replace Windows-1252 with UTF-16, but they can't bring themselves to move to UTF-8 which everyone else and the web uses instead.

PowerShell has a few rough edges, but once you get over those it's super easy. Even when you can't remember the exact syntax for a command, the built-in help makes it quick to look up.

What tool(s) have you tried using to write PowerShell scripts?

>I find this hard to believe

You find it hard to believe that someone who uses a tool daily gets to know it?