Live data from Hacker News

PowerShell is open sourced and is available on Linux

azure.microsoft.com

671–680 of 790 posts

Re: PowerShell is open sourced and is available on Linux

#671
post #616

Earlier quoted context omitted.

> And the over-verbose syntax doesn't help This is basically the reason I have not been willing to put any time even trying to learn ps. I mean, trying to translate unzip file.zip folder To ps was a nigthmare. Like: [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath) I don't _want_ to learn to type stuff like that for simple shell scripts.

But that's picking an example where a. You can still use the native binary just as well. Especially in this case. b. There was no PowerShell cmdlet for it at the time. There also isn't one for executing Python code, you still have to call python. Or, if you're so inclined, load up IronPython's assembly, and use an overly verbose .NET method call ... c. There now is a cmdlet for doing so: Expand-ZipFile. I'm actually…

If you're used to cmd or bash, the jump in verbosity is very noticeable and definitely gets in the way.

It might be a cultural thing, because I'm no fan of C# and its typical style either; no surprise then, that I find PS syntax exceedingly verbose too. It just feels excessively bureaucratic and awkward to have to write so much. On the other hand, bash, awk, sed, and all the typical Unix commands and its associated ecosystem seem like they "get out of your way" far more effectively.

c. There now is a cmdlet for doing so: Expand-ZipFile.

That example already shows the verbosity increase clearly - why is it "Expand-ZipFile", and not "ZipFile-Expand", "Expand-Zip-Format-Archive", or something else? In contrast, "unzip" is short and easy to remember. The fact that a native binary might exist for a given task is irrelevant to the observation that the shell's language is itself more verbose.

I'm actually curious as to those complaints: Do you never write a function in bash to abstract away something? A function in other languages? Is everything just a series of crystal-clear one-liners?

Abstraction helps reduce code duplication but is not useful when each line of the script is quite different, and in that case PS remains more verbose. Ultimately, the overhead is still higher.

Re: PowerShell is open sourced and is available on Linux

#672

Earlier quoted context omitted.

0: scsh is a nice scripting language, however it's not meant for interactive usage (PowerShell is) See: http://www.alphanet.ch/~schinz/scsh-faq/scsh-faq_4.html#SEC3... Scheme is also dynamically typed. 1: It's the first time I see it, but from a cursory glance and some docs ( http://hackage.haskell.org/package/turtle-1.0.0/docs/Turtle-... ) I think it doesn't include simply calling external commands (I couldn't find…

> I think it doesn't include simply calling external commands proc and inshell. Did you check out the built-in tutorial? http://hackage.haskell.org/package/turtle-1.0.0/docs/Turtle-...

You're linking to an old version. Here is the current version: http://hackage.haskell.org/package/turtle/docs/Turtle-Tutori...

Re: PowerShell is open sourced and is available on Linux

#673

Earlier quoted context omitted.

No. The well-known mature shell tools manage files and processes - neither of which are a focus of managing a Windows system. Windows revolves around services which you RPC to, which internally store their state - attempting to faff with their state from outside the service is almost always both undocumented and likely to cause failure. Powershell allowed those services to standardise their RPCs in such a way that sy…

It's been years since I used Windows APIs -- back then there was OLE Automation, which allowed dynamically, late-bound (call by name, really) RPC calls into COM from scripting languages. Has this been superceded by something else? Using IDL-defined COM interfaces from scripts sounds like something nobody would want to do.

Indeed, nobody would want to do that, which is why Powershell exists. Scripting VB or Javascript against COM or whatever else the software vendor decided to use was generally an awful experience, if the interface was even documented at all. Powershell replaces all of that for system administration purposes - you can even run Powershell commands easily from within any .Net application and get structured, object-oriented output, which is what at least all the Windows Server GUI stuff does now.

You're still stuck with OLE/COM for e.g. Excel automation, though, I think.

Re: PowerShell is open sourced and is available on Linux

#674
post #303

Earlier quoted context omitted.

Don't forget control-R. I find that even the GP's example of up arrow 20x to be ridiculous when I can type C-r and a few unique letters that were anywhere in the command to find it instantly.

Which is why any sane powershell user would probably have installed PsReadline to get this and other goodies. Preferably running in ConEmu.

PsReadline is shipped with PowerShell 5: https://technet.microsoft.com/en-us/library/ed48e832-95f9-45...

Re: PowerShell is open sourced and is available on Linux

#675
post #476

Earlier quoted context omitted.

So much this. What the M$ community fails to see is that text streams can be consumed by __everyone__. We've basically all accepted the fact that programs are used longer and in different ways than we'd expect. A brittle object model can only lead to vendor lock in and indigestible output.

It's even more than that: text formatting allows the use of generic filtering and text processing tools. Whereas if you are using objects, you will tend to use less on-the-fly command line composition, and write or reuse more tools dedicated to one particular object or the other. In the end I'm not sure keeping the structuring as the default use case yields an usage so much improved in the real world, because if you…

Structured data allows the use of generic filtering and structured data processing tools. The basic requirement is reflection, objects being able to tell you about their structural composition.

If code was stored in a structured representation you could still search for a string object containing a symbol name in the structured representation. You can match a structure pattern just like you match a regex to text.

Typical shells can be thought of as REPL for a programming language that makes the file system easily accessible and uses said file system or pipes to pass around data between functions/commands, sometimes as human-readable text. Most programming languages don't encourage passing data around as strings.

Re: PowerShell is open sourced and is available on Linux

#676
post #32

Earlier quoted context omitted.

Is this really so useful in practice? I have never used PowerShell before (nor do I have plans to do so in the near future), but I would imagine the downside is complexity, both for user and especially for developers. With text you just read and parse, while with objects you need to know the object type, its fields,... Whatever happend, I hope text stays here (and I have a bad feeling about it ever since I met system…

I've done some Powershell work in my brief time as a Windows sys-admin. I personally struggled with it. The object interaction can be complex and the naming feels less scriptable and more directly out of the C# world. That being said, I can see the appeal and I know people who love it. I have seen some amazing shit written in it, like this security tool that was just open sourced this year: https://github.com/adaptiv…

You can just use the Mono bindings for the Linux-specific API's, I hope.

Re: PowerShell is open sourced and is available on Linux

#677
post #529

Earlier quoted context omitted.

I wouldn't go so far as to call it a "horrible abortion" - but it can be painful to use at times. I manage several Azure environments with PowerShell and not a day goes by that I don't wish there was something better. Especially on those days when I have to dig into Azure's JSON templates. There is an SDK for Python, but I haven't had an opportunity to try it. If anyone has used it I would love to hear about your exp…

There are the Azure REST APIs that you can curl. Or the Azure-CLI on Linux and Windows. That said, I've noticed that powershell seems to get priority with Azure support before the azure-Cli client, so there are a few gaps here and there. I've been told that the Azure REST APIs are all in step with Powershell support, but sometimes go in documented unfortunately.

Azure CLI, Azure PowerShell and even the portal are nothing more than API clients. You can capture traffic while working with any of them and see it for yourself.

Also, for PS and CLI the code is in GitHub :)

Re: PowerShell is open sourced and is available on Linux

#678
post #9

I'm always in favor of things being open-sourced, but I do kind of wonder in what universe I would use PowerShell when Bash is readily available.

It is just another tool in the toolchest. As you know, on Linux, there are tons of great interactive shells and it is sortof a lifestyle choice. You might want to kick the tires and see whether it fits your lifestyle or not. If you use Bash as your shell, think of PowerShell as you would python or perl - something you write scripts in and call from Bash. Jeffrey Snover [MSFT]

Thank you for doing this!

Anyone who's done any kind of if else while for in bash/zsh and powershell knows what a relief PowerShell is. I'd love for PowerShell (PSReadline actually) to support the common options of readline- e.g. HISTIGNORE, HISTCONTROL etc

Re: PowerShell is open sourced and is available on Linux

#679
post #368
post #336

Earlier quoted context omitted.

> Could you elaborate on what the actual complexity is, rather than what you imagine? I can only use this feature by using a .NET language. I can't take the strongly typed objects into a Node.js script, or a perl script.

>I can only use this feature by using a .NET language. It goes without saying that a binary interface requires use of a system that understands that particular binary interface. With .NET being open source though, anyone is free to write a bridge to using the objects in COBOL if they wanted to. >I can't take the strongly typed objects into a Node.js script, or a perl script. Yes, because they have no concept of stron…

The point is that this thing is less valuable by being limited to only being used by things that Microsoft created (in reality). Text, with all of its flaws, can be used by everything.

Re: PowerShell is open sourced and is available on Linux

#680
I don't want to be that smug ITT guy but it has to be said:

Bash != Readline and Bash != coreutils and Bash != (what gives your machine the ability to do ssh)

Bash is the stupid if for while syntax

You have Readline in powershell and you can use coreutils binaries in Powershell. No problems there.

Post reply on HN