r/linuxadmin • u/speckz • Aug 18 '16
Microsoft open sources PowerShell with .deb/.rpm packages
https://github.com/PowerShell/PowerShell32
u/LinuxUser437442 Aug 18 '16
I'm sorry, did hell freeze over? Also, why the hell would I use powershell when I have bash/zsh/etc?
17
u/zoredache Aug 18 '16
I would guess it will probably be easier to manage Windows boxes remotely from Powershell on your Linux box.
Sure you could already do this sorta using the winrm libraries in python and a couple other languages, but it wasn't particularly easy. Though it wasn't that bad when done via ansible.
8
u/doublenns Aug 18 '16
Probably also ties into their initiatives w/ their Azure cloud.
7
u/cajuntechie Aug 19 '16
This probably is all about Azure. Microsoft doesn't care what OS you use anymore. All they care about is that you have good access to Azure.
2
u/LinuxUser437442 Aug 18 '16
I guess that would be a good reason. But still, like you said, there are other ways.
5
18
u/fifthecho Aug 18 '16
Two words - object pipeline.
Rather than passing strings through the pipe, PowerShell passes full C# objects down the pipe, so you can pass an object like a full JSON document through the pipe and have different parts of the pipeline accessing different keys from each JSON object in the document. No more funky-ass
sedandawkto try and extract values from keys.12
u/xMadDecentx Aug 18 '16
Or could just use Python's JSON API.
-3
u/Rollingprobablecause Aug 18 '16
Gross..
5
Aug 18 '16
You would rather parse in powershell than in python?
4
u/Rollingprobablecause Aug 18 '16 edited Aug 18 '16
that's purely subjective, parsing in either can be a pain depending on input. Also they both have versions that suck at it (POSH v3 and below, Python 2.7 and below...)
EDIT: I meant input as far as array/code various arrays, etc. People forget the difference between shell scripting and object programming a lot.
3
1
u/aim2free Aug 18 '16
I would assume that python is a more general programming language. Hmm, here I see a comparison, don't like. PowerShell looks like perl o php.
4
u/the_gnarts Aug 18 '16
Rather than passing strings through the pipe, PowerShell passes full C# objects down the pipe, so you can pass an object like a full JSON document through the pipe and have different parts of the pipeline accessing different keys from each JSON object in the document. No more funky-ass sed and awk to try and extract values from keys.
Just another REPL, then, isn’t it?
4
u/fifthecho Aug 18 '16
In many ways, yes. However, it can directly execute code without any funky-ass shell-outs.
But then, I guess by that definition, isn't Bash/ZSH/CSH a REPL for their respective languages?
1
u/aim2free Aug 18 '16
But then one would need to use C#, which I don't. I don't even know if there are any GPL/CopyLeft licensed C# environments.
I could possibly see the point if it could be generalized to any kind of objects, in scheme, common lisp, python etc, but that is not very hard to do anyway.
4
u/fifthecho Aug 18 '16
POSH itself is C#. POSH commands are not C#.
Also, all of the .NET CLR has been released under the MIT License
And for the C# runtime itself, Mono is released under the MIT License as well.
2
u/aim2free Aug 19 '16
I have so far missed the point with .NET. I feel a connection with MS and that I definitely don't want. If this bundling between hw and sw could come to an end so you could buy exactly any machine you want without OS, or with an OS of your preference then it could be more interesting, but as long as there is this bundling I won't accept any ties to MS.
2
u/bobthecowboy Aug 18 '16
I think the better comparison would be using something like python, perhaps? Or Xonsh?
1
u/dogfish182 Aug 19 '16
Because an object orientated shell is arguably better, also cross platform is best platform
1
1
u/sudo-is-my-name Aug 18 '16
If you work in IT this is great. I can work on my powershell scripts from the OS of my choice and get paid for it. That's a huge win.
0
Aug 18 '16
[deleted]
2
u/LinuxUser437442 Aug 18 '16
That I did not know. Explains why I never really understood it very well. Unless there are plans for Linux to get more object oriented, which I guess systemd is doing somewhat, it just seems like a PR move rather than a great technical advance move.
1
u/aim2free Aug 18 '16
I use bash for simple text maninpulation, I use e.g. python to deal with objects. In what way can powershell make things simpler?
1
u/cris9288 Aug 18 '16
Could be a sign that they are bringing over more MS products to Linux as they seem to pushing admins more and more towards Powershell for management and automation.
1
u/MEaster Aug 19 '16
Powershell runs on top of .Net, which has also been ported to Linux. The only way I've heard of to interop with Win32 directly from Powershell involved quite the hack.
What the person did was have a string of C# code in his Powershell script. He then called the C# compiler from within his script, holding the resulting assembly in memory. He then loaded the assembly, used reflection to obtain a reference to the function he'd written, then executed it.
Just so he could set the desktop background.
1
u/here-to-jerk-off Aug 21 '16
but don't applications have to output those objects to an API that Powershell understands?
6
9
u/sentient_penguin Aug 18 '16
Just installed it on one of my dev boxes. Still though... learning a new language (essentially) just to do things we already know how to do seems a bit of a .... waste of time. I get that RedHat is trying to push the partnership, but we already have tools that work with everything. I get that MSSQL can now be put onto Linux (and works great), but still not sure why we need it. Probably for teams who are moving to Linux but were previously Windows Admins/Engineers.
4
u/Rollingprobablecause Aug 18 '16
but were previously Windows Admins/Engineers.
Pretty much. A lot of us run mixed environments and /r/linuxadmin is just the admin portion, when you're a programmer, scripting tools in wide swaths are never a bad thing.
3
u/anderbubble Aug 18 '16
learning a new language (essentially) just to do things we already know how to do seems a bit of a .... waste of time
That's a remarkably solipsistic perspective.
1
u/neutral_cadence Aug 19 '16
It could go both ways. Not everyone runs a hybrid environment or wants to invest in something that could hold little significance in their work.
2
u/anderbubble Aug 19 '16
Maybe it's not for such people. But that's far from it being a "waste of time."
1
u/neutral_cadence Aug 19 '16
It'd be a waste of time to anyone who has no use for it...I also understand that yeah, he hardly speaks for everyone. We run a hybrid environment so I'm kind of excited to see this and get a little more familiar.
10
u/TokinRing Aug 18 '16
Why would I EVER want to use powershell on a *nix box?
13
Aug 18 '16
I can imagine a few use cases, mostly relating to mixed environments. If you're a Windows guy with a handful of *nix servers, being able to put PoSH on them and have a uniform ui between them sounds pretty handy. It's more or less the same reason you might want ssh on a Windows machine.
We all know that bash is an imperfect system. It does what it was meant to do but it has some pretty strict limitations. The traditional workaround is to use $scriptinglanguage for anything heavy. (Python is the sexy these days, but it was Perl when I started). I'm not going to lie, though, the idea of an object-oriented shell environment is something that intrigues me. Maybe I don't want PoSH exactly but maybe someone can use the ideas here to implement something nice for Linux and then that's still a win.
Basically it's my opinion that open source is never bad.
2
u/central_marrow Aug 18 '16
I was thinking the other way round - if you're Linux/OS X shop with a few Windows servers, you now have one less reason to keep a Windows desktop around to manage them.
1
u/ElBeefcake Aug 19 '16
You could always install an SSH server on a Windows Server and get in that way.
4
3
u/ahandle Aug 18 '16
You know - to manage all those FreeBSD Azure instances or remotely manage BoW installs on W10.
3
3
3
u/ForceBlade Aug 18 '16
I don't need this but like the direction they've taken. But that's probably why they did it
9
2
Aug 18 '16
It seems pretty fuckin' buggy. The help "Update-help" won't install. I'll check back in a few months. Maybe.
1
3
u/shinjiryu Aug 18 '16
Ah, Powershell. Microsoft's attempt to get the MS shell closer to *NIX in power and flexibility. I'm glad to see they open-sourced it, as it allows us to peek inside of what the codebase is. Now, while I may never use it, I am glad to see that this is a possibility if a use case arises where PS would be useful in a non-MS environment.
1
1
u/happysysadm Aug 22 '16
The biggest issue will be all the aliases that PowerShell uses and that match linux commands but don't do exactly the same (i.e. sort for sort-object). So no fancy as-short-as-you-can oneliners.
-6
u/hackel Aug 18 '16
Huh? Isn't power shell just an interface to windows dos emulator? How would this even work? Does it convert Linux mount points to drive letters or some such nonsense? This is just bizarre.
2
u/aedinius Aug 19 '16
No, it isn't.
The paths appear as they normally do, and as you'd expect (/home/whatevs)
2
u/gbrayut Aug 19 '16
It works as an interpreter like Ruby or Python but using .NET core and an object based pipeline for the REPL
1
u/hackel Aug 23 '16
Wow, never would have imagined we'd see something so advanced on Windows of all places! I thought they were happy with their batch files...
0
Aug 18 '16
[deleted]
3
u/gbrayut Aug 19 '16
Workaround at https://news.ycombinator.com/item?id=12314693 and issue for Fedora rpm at https://github.com/PowerShell/PowerShell/issues/1882
26
u/grendel_x86 Aug 18 '16
Sweet, I can install powershell on Ubuntu on my Windows box!
:D