People laugh at me when I tell them I switched "back" to Windows after decades of Unix and Mac programming. But it's a really good, productive platform. Microsoft really seems to be heading in the right direction now. I hope .NET starts taking off on other platforms, too, because it really is a much better system than Brand "J".
PowerShell is open sourced and is available on Linux
151–160 of 790 posts
Re: PowerShell is open sourced and is available on Linux
#152Earlier quoted context omitted.
I was about to refute you with a recent example of mine that just needed to serially execute a bunch of commands, and it's well over 20 lines. Then I remembered that I needed to introduce some branching logic, said "not in bash, I'm not", and rewrote it in Python. So for me, it's not a matter of LoC but complexity. Need to copy file from here to there, then commit to git repo, blah, blah, blah, then kick off a build?…
Well it isn't a hard limit. I am okay with a 25 line script for example ;) Well really you are more right than me. It is about complexity more than the number of lines. However for the most part the longer something is the more complex it is to work with even if it does something simple. Managing a 1000 line bash script is almost certainly going to be more painful than doing it "properly" in Python or Java or whateve…
Thanks for taking the time to reply. And you're right, even I wouldn't want to maintain 1000 lines of serially-executed commands, meaning I have a line limit somewhere as well. So maybe a mix of complexity, and at some point length even if I don't put a number on it like you did.
Re: PowerShell is open sourced and is available on Linux
#153Earlier quoted context omitted.
How would that be hard in a *nix shell? mysql > SELECT column_name, data_type, numeric_precision FROM information_schema.columns WHERE table_schema = ? AND table_name = ? AND column_name LIKE "%int%"
Imagine for a second that the DB can't do it and you need to filter the STDOUT output.
Fortunately, that's not a world any of us live in.
Re: PowerShell is open sourced and is available on Linux
#154powershell, 14 pids(threads?), 3119M Virt size, 80160kb Resident.
bash, 1 pid, 22068kb Virt, 3976kb Resident.
And this is simply starting the process to an idle prompt.
This is on a Debian 8 64bit system. (using their Ubuntu 14.04 binary)
Re: PowerShell is open sourced and is available on Linux
#155Earlier quoted context omitted.
Ok, that sounds good. But what if some developer decided that some field would have prefix "ABC" in all values, then the value I am interested in, then some value I am not interested in at the end? (you say this can't happen? Clue: WMI.) Can I take the value, convert it to string, make some magic on it and convert it to another object entirely? I don't know, I never had any problems with text parsing. I love strong t…
Yep! There's a few ways to accomplish such a thing, but probably the most straight forward would be the Foreach-Object command (aliased as "%") to do a mapping from source object to something else. Free form objects/dictionaries are easy to make and consume.
Re: PowerShell is open sourced and is available on Linux
#156Earlier quoted context omitted.
As a note, there have been strongly-typed shell languages for Unix for some time. Scheme Shell[0], Turtle[1] and TCSH[2] leap to mind; but there's nothing preventing a developer from using Perl, Python, Lisp or any other language that allows itself to accept stdin as an interpreted script. 0: https://scsh.net/ 1: http://www.haskellforall.com/2015/01/use-haskell-for-shell-s... 2: http://www.tcsh.org/Welcome Edit: oh m…
This is why I find PowerShell to be an answer to a question nobody asked. If bash/zsh isn't cutting it for you, drop into something like Python, Ruby or Perl to do the heavy lifting. PowerShell will never accumulate a library as comprehensive as what any of those three have, each has had decades to accumulate packages of all kinds, and more are still being added. It's odd, but not surprising given their history of "N…
Re: PowerShell is open sourced and is available on Linux
#157Earlier quoted context omitted.
I find it massively useful in practice, even for mundane tasks. For example, the other day I was trying to search the columns of a very large SQL Server table¹ but also needed information about the column type. …\dbo.site> ls Columns | select Name, DataType, {$_.Properties['Length'].Value} | where {$_.Name -like '*int*'} Name DataType $_.Properties['Length'].Value ---- -------- ----------------------------- internal_…
How would that be hard in a *nix shell? mysql > SELECT column_name, data_type, numeric_precision FROM information_schema.columns WHERE table_schema = ? AND table_name = ? AND column_name LIKE "%int%"
Point is, imagine trying to grep anything tabular in bash. Hypothetically, the output of ls -la for files with execute permission that have been modified in the last day. Or, more realistically, anything involving ps.
Re: PowerShell is open sourced and is available on Linux
#158Earlier 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…
It's nice when it works, but it's a pain to write a command-line utility that outputs into objects. Whereas in Unix, everything automatically outputs into text, so you have to work hard to prevent it from being chainable to the system. There are also details of Powershell that are very annoying, such as the lack of < redirect, and the difficulties it has on binary output sometimes.
Re: PowerShell is open sourced and is available on Linux
#159Earlier quoted context omitted.
Objects are discoverable in powershell. Enter the object, and lists the object out as text.
Ok, that sounds good. But what if some developer decided that some field would have prefix "ABC" in all values, then the value I am interested in, then some value I am not interested in at the end? (you say this can't happen? Clue: WMI.) Can I take the value, convert it to string, make some magic on it and convert it to another object entirely? I don't know, I never had any problems with text parsing. I love strong t…
https://technet.microsoft.com/en-us/library/ff730948.aspx
You use the exact same functions (first, last, substring, replace, etc) as you would normally. Then the rest of the pipeline has it available if needed.
Re: PowerShell is open sourced and is available on Linux
#160>We will be extending the PowerShell Remoting Protocol (MS-PSRP) to use OpenSSH as a native transport. Users will have the option to use SSH or WINRM as a transport. Is possibly an even bigger announcement (this means there's actual momentum behind https://github.com/PowerShell/Win32-OpenSSH )
This is what I have been waiting for right here!