Live data from Hacker News

Two Months with Powershell on a Unix

code.joejag.com

51–60 of 113 posts

Re: Two Months with Powershell on a Unix

#51

I spent some time with Powershell on Windows recently, more time than I am used to. Powershell is a clear winner over CMD.EXE by a mile, but… - As an interactive shell, it suffers from an ecosystem which is much poorer than the bash/zsh ecosystem, - As a scripting language, I’m going to use Python or Go the moment anything becomes larger than a few lines, - Installing Posh Git is just a really mediocre experience (in…

yeah I use to automate a decent amount of stuff for bigger deployments for client with it as it’s easier to pass through security audit then an executable.

I always feel like things in power shell are harder then they need to be that other scripting languages I don’t have that problem. One thing I do like is being able to leverage .net locally and also import DLLs. That helps me get around a bunch of gaps.

Re: Two Months with Powershell on a Unix

#52
post #7

If you don't want PowerShell reporting your activities back to the mothership, don't forget to set POWERSHELL_TELEMETRY_OPTOUT=1 in your environment before launching PowerShell!

A shell with telemetry. Insane.

Wow... would have never thunk it

Re: Two Months with Powershell on a Unix

#53
post #17

Earlier quoted context omitted.

This 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"

FWIW, I already have a command line tool that can do that installed in regular Unix: 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?

There 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 .

Re: Two Months with Powershell on a Unix

#54

I spent some time with Powershell on Windows recently, more time than I am used to. Powershell is a clear winner over CMD.EXE by a mile, but… - As an interactive shell, it suffers from an ecosystem which is much poorer than the bash/zsh ecosystem, - As a scripting language, I’m going to use Python or Go the moment anything becomes larger than a few lines, - Installing Posh Git is just a really mediocre experience (in…

My biggest issue with powershell is how undiscoverable it is. Good luck doing anything without searching for commands in a web browser.

But maybe that's just a result if it being so new. 'ls' has been around for almost 50 years...

What it really feels like is a complete programming language inside of notepad.exe because of the historically terrible windows command prompt.

Re: Two Months with Powershell on a Unix

#55
post #36

Earlier quoted context omitted.

powershell is ok, I guess, but the core issue is it's over-engineered. Bash is weird, but it is everywhere and it's simple, and that simplicity is going the be very difficult to replace. How do replace nothing? I love Python, do switch to it. ( The windows and MS stack is utter balls )

> the core issue is it's over-engineered. I wouldn't call it over-engineered. Ambitious? Maybe, but I don't see PowerShell lagging behind in any front it's designed for.

Honestly my biggest complaint is just that it's more verbose than bash which is admittedly pretty cryptic at times. Now that I've learned bash though, I have little need to move to PowerShell.

Bash is tough to learn at first because its syntax is alien but I've learned enough to get things done with it.

Re: Two Months with Powershell on a Unix

#56

I am dead serious. Powershell should replace (bash) shell scripting under any Linux. I find shell scripts terrible, I've learned to switch to Python quickly, despite the overhead. Powershell is very command-line friendly, with easy tab-completion of commands. I've worked with it extensively on Windows, creating large worklflows with it, it's very nice. Powershell even has a unit test tool called 'pester' which is fun…

I don't know what your native language is, but in English "pester" means to annoy. A negative connotation no matter what. I don't get the hate on Bash though. It's a natural extension of the command line, and works quite nicely to get a lot done without the overhead. Deployment is a lot easier in my environment (web hosting) because all of the servers are homogenous, and I don't need to worry about any dependencies b…

>I don't know what your native language is

Dutch?

Re: Two Months with Powershell on a Unix

#57

>For example, if we wanted to get the first three files from ls I’d do something like `ls | head -n 3`. In Powershell, it’s `$(dir)[0..2]` since the dir command is returning an array which I can index into. You could do that, but the way to write it in the bash way would be `dir | select -first 3` >a quick Google told me to use `echo | openssl s_client -showcerts -servername joejag.com -connect joejag.com:443 2>/dev/…

> You could do that, but the way to write it in the bash way would be `dir | select -first 3`

I would have said "ls | head -n3" as well. I've never heard of "select". I just tried your suggestion and it doesn't appear to work:

    $ dir | select -first 3
    bash: syntax error near unexpected token `3'

Re: Two Months with Powershell on a Unix

#58

>For example, if we wanted to get the first three files from ls I’d do something like `ls | head -n 3`. In Powershell, it’s `$(dir)[0..2]` since the dir command is returning an array which I can index into. You could do that, but the way to write it in the bash way would be `dir | select -first 3` >a quick Google told me to use `echo | openssl s_client -showcerts -servername joejag.com -connect joejag.com:443 2>/dev/…

>You could do that, but the way to write it in the bash way would be `dir | select -first 3`

Fyi, `dir | select -first 3` also works in PowerShell.

Re: Two Months with Powershell on a Unix

#59

I spent some time with Powershell on Windows recently, more time than I am used to. Powershell is a clear winner over CMD.EXE by a mile, but… - As an interactive shell, it suffers from an ecosystem which is much poorer than the bash/zsh ecosystem, - As a scripting language, I’m going to use Python or Go the moment anything becomes larger than a few lines, - Installing Posh Git is just a really mediocre experience (in…

Hey, I use PowerShell on Windows a lot. Some advice that I hope helps for installing posh-got specifically is to “git clone” the posh-git repo. Then in your $Profile.CurrentUserAllHosts do an Import-Module for the PSM.

I know all this is personal and subjective. I think using git to manage this is pretty easy and safe. If and when I want to update it’s as simple as doing a git pull in my local repo of posh-git and reloading the shell.

If the new version is broken (has never happened yet but ya know.. in case) just checkout the previous one.

I have found using git, the powershell user profile and modifying my user path when necessary is the best way of managing dev dependencies on Windows.

I also understand why people want this all abstracted away from them in a package manager.

Post reply on HN