Microsoft PowerShell goes open source and lands on Linux and Mac
-
-
That's awesome. Especially if a remote management endpoint is exposed on a Linux machine and if you can use RM to hit a Windows machine from the Linux machine.
-
bash on Windows, PowerShell on Linux, what is the world coming to?
-
Very nice - so its an opportunity to try powershell - and I heard its modern and powerful.
Could you recommend some tutorial or article about?- what can be achieved with powershell
- getting started and learning about it
Thanks
-
@mott555 said in Microsoft PowerShell goes open source and lands on Linux and Mac:
bash on Windows, PowerShell on Linux, what is the world coming to?
I'm confused about why this post was worth a downvote from someone...
-
@Adynathos said in Microsoft PowerShell goes open source and lands on Linux and Mac:
so its an opportunity to try powershell
You could have tried Pash, which was probably pretty close.
@Adynathos said in Microsoft PowerShell goes open source and lands on Linux and Mac:
what can be achieved with powershell
The same things as, say, bash. Except everything is object oriented, so when you
ls
, you're seeing the string representations of FileInfo objects, which have a lot of data available.@Adynathos said in Microsoft PowerShell goes open source and lands on Linux and Mac:
getting started and learning about it
Launch it, type
man ls
-
@mott555 said in Microsoft PowerShell goes open source and lands on Linux and Mac:
I'm confused about why this post was worth a downvote from someone..
for teh lulz? (for the record, i upvoted. see, my name even appears in the list and everything)
-
@Magus said in Microsoft PowerShell goes open source and lands on Linux and Mac:
Except everything is object oriented, so when you ls, you're seeing the string representations of FileInfo objects
Yes, this is great :)
And when i store the result of a command, I can use tab-completion to see the list of available methods to call.(get-process gedit).Kill()
@Magus said in Microsoft PowerShell goes open source and lands on Linux and Mac:
Launch it, type man ls
I think the help command is
get-help
-
@Adynathos It is, but
man
andls
are aliased, because they wanted bash users to feel at home.
-
@Adynathos Yes, but man is an alias to it.
-
> man get-process No manual entry for get-process
man
executes the Linux programman
.
But that is completely ok,get-help
is a much more meaningful name for getting help thanman
.There is
ls
but it returns a list of strings but it is actuallydir
that returns a list ofSystem.IO.FileSystemInfo
.> (ls)[0].GetType() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True False String System.Object > (dir)[0].GetType() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True False DirectoryInfo System.IO.FileSystemInfo
Anyway, types in a shell - so beautiful!
-
@Adynathos Huh. Interesting.
-
@Adynathos said in Microsoft PowerShell goes open source and lands on Linux and Mac:
man executes the Linux program man.
But that is completely ok, get-help is a much more meaningful name for getting help than man.
There is ls but it returns a list of strings but it is actually dir that returns a list of System.IO.FileSystemInfo.Ah, that must be because there are real programs for those on linux. I'm used to running it on Windows. Yeah, the real names are going to be better in general.
But yeah, types are really nice, and something that a shell really ought to have.
-
A nice way to find commands is the Get-Command cmdlet, as a note. You can then pipe it to something to narrow things down if you're looking for something specific.
-
@Erufael said in Microsoft PowerShell goes open source and lands on Linux and Mac:
You can then pipe it to something to narrow things down
I found that you can even do
get-command regex
and will narrow down to the regex.Anyway, Powershell seems like a worthy alternative to Python for writing shell scripts.
-
@Adynathos Yeah. I'm trying to remember what we did in the Windows Cmd/Powershell class I took last fall. lol
-
@mott555 said in Microsoft PowerShell goes open source and lands on Linux and Mac:
@mott555 said in Microsoft PowerShell goes open source and lands on Linux and Mac:
bash on Windows, PowerShell on Linux, what is the world coming to?
I'm confused about why this post was worth a downvote from someone...
Most likely the "I'm scrolling on mobile! Downvotes I sprinkle around because lol touchscreen!"
-
@mott555 said in Microsoft PowerShell goes open source and lands on Linux and Mac:
@mott555 said in Microsoft PowerShell goes open source and lands on Linux and Mac:
bash on Windows, PowerShell on Linux, what is the world coming to?
I'm confused about why this post was worth a downvote from someone...
You must've counted wrong, because there are 8 upvotes and the post has a score of 8.
-
Sane loops, sane string formatting, no end to the surprises :)
foreach($fn in (dir)) { "{0} has extension {1}" -f $fn.Fullname, $fn.Extension }
-
@ben_lubar When I posted that, it had a score of -1.
-
@mott555 well, whoever downvoted it un-downvoted it.
-
@ben_lubar
If it's important I can down vote it just to mess with @mott555 's head
-
@Luhmann someone may have scrollvoted down
-
My new powershell script to run after every windows update:
Get-AppxPackage *officehub* | Remove-AppxPackage Get-AppxPackage *skypeapp* | Remove-AppxPackage Get-AppxPackage *OneConnect* | Remove-AppxPackage Get-AppxPackage *Asphalt8Airborne* | Remove-AppxPackage Get-AppxPackage *CandyCrushSodaSaga* | Remove-AppxPackage Get-AppxPackage *FarmVille2CountryEscape* | Remove-AppxPackage Get-AppxPackage *getstarted* | Remove-AppxPackage Get-AppxPackage *bingfinance* | Remove-AppxPackage Get-AppxPackage *Netflix* | Remove-AppxPackage Get-AppxPackage *zunevideo* | Remove-AppxPackage Get-AppxPackage *bingnews* | Remove-AppxPackage Get-AppxPackage *PandoraMediaInc* | Remove-AppxPackage Get-AppxPackage *windowsphone* | Remove-AppxPackage Get-AppxPackage *bingsports* | Remove-AppxPackage Get-AppxPackage *Office.Sway* | Remove-AppxPackage
edit: I used http://www.tenforums.com/tutorials/4689-apps-uninstall-windows-10-a.html to get the magic names.
-
Meh.
In the SSH-centric world, any shell other than bash is useless.
Unless you can convince everyone else to adopt zsh or ps or whatever flavor you like the best, once you start doing real admin/devops stuff, you end up in bash anyway. So you might as well get used to it, instead of spreading your resources thin on mastering other shells.
-
@Magus said in Microsoft PowerShell goes open source and lands on Linux and Mac:
man ls
get-help get-childitem
-
@Adynathos said in Microsoft PowerShell goes open source and lands on Linux and Mac:
There is ls but it returns a list of strings but it is actually dir that returns a list of System.IO.FileSystemInfo.
Oh, that might be why I can never fucking remember what the hell I was supposed to be doing with those damn
ls
results. Do IForEach-Object
over them, do I pipe them to a command, do I have to extract the property from$_
, do I have toSelect-Object
, do I need the$()
brackets, in or out of double-quotes, GAH!It's awesome if you put some time into it and try to figure it out. I just kinda never did.
@cartman82 said in Microsoft PowerShell goes open source and lands on Linux and Mac:
Unless you can convince everyone else to adopt zsh or ps or whatever flavor you like the best, once you start doing real admin/devops stuff, you end up in bash anyway. So you might as well get used to it, instead of spreading your resources thin on mastering other shells.
Yes, because all "real" admin/devops stuff is done on *nixes. Windows servers are just child toys, psh.
-
@Maciejasjmj said in Microsoft PowerShell goes open source and lands on Linux and Mac:
Yes, because all "real" admin/devops stuff is done on *nixes. Windows servers are just child toys, psh.
Sorry, but increasingly so, yes.
If you disagree, go tell Microsoft. They seems to think so too.
-
@dcon Nice! I finally managed to delete that stupid OneNote app that way, which I'm otherwise unable to uninstall.
-
I wonder how they deal with the ACL system difference.
Say, does it just count what's in /etc/group and /etc/passwd like on standard *nix systems, or will they also count what's on enabled PAM modules like LDAP or Winbind?
-
@cheong said in Microsoft PowerShell goes open source and lands on Linux and Mac:
I wonder how they deal with the ACL system difference.
Say, does it just count what's in /etc/group and /etc/passwd like on standard *nix systems, or will they also count what's on enabled PAM modules like LDAP or Winbind?
Standard *nix systems haven't even done that for a while now. I can do
id
on any domain user when my servers are joined and get all their domain groups in addition to any local group memberships, give them permissions to files, etc. So I imagine it'll tie into PAM/NSS like anything else.
-
New-Alias oldname newname
is pretty fun, depending on what you rename things to, I've discovered.
-
@Maciejasjmj said in Microsoft PowerShell goes open source and lands on Linux and Mac:
It's awesome if you put some time into it and try to figure it out.
When you have, what you realize is that the cure (every! fucking! thing! is a special case) is worse than the disease (string interpolation tends to go wrong) ever was.
PowerShell attempts to be clean and tidy and well-designed in order to prevent the kind of mess you can get into if you're not good at writing bash scripts, and as a result it suffers incredibly badly from bash bug 1 (it's too big and too slow).
As a fluent bash scripter, I find using PowerShell much like trying to ride dirt trails on a Honda Gold Wing.
-
@flabdablet said in Microsoft PowerShell goes open source and lands on Linux and Mac:
if you're not good at writing bash scripts
I know a lot of people who think they're good at writing bash scripts. The horrors!
@flabdablet said in Microsoft PowerShell goes open source and lands on Linux and Mac:
As a fluent bash scripter,
The problem is that mastering bash (and all edge cases) is hard. Even experts write sometimes scripts which break e.g. when when they encounter a file named "-rf". Using PowerShell correctly, OTOH, is easy.
-
@asdf said in Microsoft PowerShell goes open source and lands on Linux and Mac:
Even experts write sometimes scripts which break
I don't, but then I don't use bash (which is hard to use in a robust way). The problem isn't the types or the lack of them per se, the problem is that meta-level things are indistinct from the actual objects being manipulated.
-
@dkf said in Microsoft PowerShell goes open source and lands on Linux and Mac:
meta-level things are indistinct from the actual objects being manipulated
The very simple habit of using -- to mark the boundary between options and parameters subject to assorted kinds of expansion kills that issue stone dead for 99% of the available tools, and does so in such a way as not to bury the intent of the command under a scrapyard of syntactical boilerplate.
-
@flabdablet said in Microsoft PowerShell goes open source and lands on Linux and Mac:
The very simple habit of using --
If that was consistently supported by all command-line applications, that'd be great. Unfortunately, that's not the case, so you always have to check the man page before using that "solution".
-
@asdf said in Microsoft PowerShell goes open source and lands on Linux and Mac:
Unfortunately, that's not the case, so you always have to check the man page before using that "solution".
In practice, you end up with a set of programs where you know exactly whether they support it or not, and it's just with others you need to be more careful. Also, using types probably won't help very much with those as they won't usually be shell builtins or have the descriptors in place to allow for typing of the arguments. (If there's no type signature, you're left stuck with what you have right now.) Nobody sane proposes making everything a shell builtin! Lots of stuff — the big majority in fact — works just fine as a normal subprocess.