4 ms·
Dude has more patience than me. I tried running powershell on linux a few times, and every single time the second command I run is not supported on linux. I d
by dijit 7y ago
Dude has more patience than me.
I tried running powershell on linux a few times, and every single time the second command I run is not supported on linux.
I don't even remember what the commands were, PSremoting was one for sure and I think another was Invoke-WebRequest.
Powershell on linux is a nice idea but in the current form it is in name only, as nearly nothing works.
- larntz 7y agoI use powershell on linux occasionally. Primarily with the azure and powercli modules. For doing vmware and azure stuff I can't think of anything that hasn't worked. If you want to do anything that would be windows only then you're right, it probably won't work. That said, I usually have a tmux window ssh'd into a windows machine for powershell. It would be nice to be able to manage ad and exchange from a linux machine with powershell.
- vips7L 7y agoInvoke-WebRequest most certainly runs on linux.
- dijit 7y agoI just attempted to prove you wrong, but it does look like it's fixed. So is creating secure strings. Cool!
- jodrellblank 7y agoCreating secure strings isn't exactly fixed; the type exists but they aren't encrypted in memory on Linux because it doesn't have the DPAPI (Data Protection API) from Windows: https://github.com/PowerShell/PowerShell/pull/9199 https://github.com/PowerShell/PowerShell/pull/9199
- danudey 7y agoThis comment made me go and try out Invoke-WebRequest because I'd forgotten what it was like. Being able to do simple web scraping like this in a "shell" is pretty great: $hn = Invoke-WebRequest https://news.ycombinator.com/ $hn.AllElements | Where {$_.TagName -eq "a" } | Where { $_.Class -eq "StoryLink" } | select "innerHtml"
- vips7L 7y agoIWR and ConvertFrom-Json are what got me hooked on powershell. No more learning complex switches for curl or crazy JQ syntax. It's all built in and makes sense.
- earthboundkid 7y agoFWIW, I already have a command line tool that can do that installed in regular Unix: https://github.com/ericchiang/pup https://github.com/ericchiang/pup The docs even use the same example of scraping HN. How does Invoke-WebRequest decide if it’s looking at HTML or something else?
- jve 7y agoWell, you use Invoke-RestMethod for JSON/XML stuff. Or decide yourself for Invoke-WebRequest to pipe it with whatever the data: ConvertFrom-{JSON,XML,CSV} With Invoke-WebRequest you get back headers, raw response, etc - and you get to decide whats next. With the RestMethod - just the content as an object.
- ct520 7y agoThere is an param to declare response type parsing and if you want to use different parsing. Older versions of powershell use IE and webrequest will randomly barf. It really sucked. You can also use a rest request method that uses json.net to deserialize I believe .
- m0xte 7y agoI’m not sure I could cope with that. I have enough problems with it on windows. Literally every corner you turn something punches you in the balls or turns to dust in your hands. It’s one of the most frustrating things I’ve ever used and I avoid it where I can. I would not invite it onto a *nix machine voluntarily where there are established patterns and solutions which have matured over the space of 40 odd years now.
- munchbunny 7y agoWhere does that happen for you? In my experience with PowerShell on Windows, you have to approach it more like interactive python with shortcuts rather than a regular shell, and once you’re accustomed it works fine. The main issue is that it doesn’t work like a classic shell, it just has some affordances to look like a classic shell in common use cases.
- danudey 7y agoAgreed; it's a lot more like a really weird iPython than it is a drop-in bourne shell replacement with quirks.
- emodendroket 7y agoIt's weird but once you get used to it I think it's cool. No more text munging!
- m0xte 7y agoWell it’s not the concept but the implementation that is at fault. From persistent random WinRM failures, sudden things breaking and the whole thing wrapping rancid bits of WMI and COM which leak through regularly, it’s just pain. On top of that the interface is somewhat flakey and slow. Plus some of the semantics feel like going back to circa 1995 Perl. Oh and don’t get me started on the nightmare that is script signing and security which really does nothing useful other than get in the way. It really feels immature. The biggest travesty is when it is integrated into something else such as ansible, packer, chocolatey etc where it will cost you a couple of days occasionally due to some obscure issue hidden behind even more layers.
- pgsbathhouse2 7y agoInvoke-WebRequest doesn't even work correctly on windows for a large amount of very vanilla web functionality. Powershell is a nice idea, but Microsoft is kidding themselves if they think it's even close to the alternatives.
- bishalb 7y agoCan you give any example? This hasn't been my experience.
- pgsbathhouse2 7y agoYou can literally just go to the list of issues on github and sort by most commented and look at their dates to see they're still relevant issues. This the dumbest type of HN question. You could have discovered it yourself in < 1 minute but you apparently refuse or might just not be able to (of which I sincerely apologize). Also your comment history should warrant a general silence. Fuck you and fuck dang and PG.
- zovin 7y agoSame here. I love using pwsh 7 on windows, but on Linux it was a whole different experience. Granted I was trying to use it on an Arch instance, which isn't technically supported, but I couldn't even get PSGet or PsReadLine to work. However, I was pretty great to run the same scripts cross OS with basic commands like Invoke-WebMethod/Invoke-RestMethod