Live data from Hacker News

In defense of PowerShell

benwilson.me

61–70 of 82 posts

Re: In defense of PowerShell

#61
post #52
post #11

I dislike windows (and by extension, powershell) because a solution such as changing the port the webserver runs on looks something like: New-ItemProperty IIS:\sites\DemoSite -name bindings -value @{protocol="http";bindingInformation=":8081:"} http://www.iis.net/learn/manage/powershell/powershell-snap-i... What did I just modify? Is it persisted to the hard disk? How do i back that up? How do I revert the change? How…

So how would you accomplish the same task on Linux using bash? What script would you write to set the web server's port to 1234?

You could just use sed and do a regex substitution that's what I use in similar instances.

Re: In defense of PowerShell

#62

I started off as a PowerShell fan, but my introductory experience has been pretty poor. A little while back, I tried testing the output of a sorting algorithm with PowerShell. I wrote a line of bash to check my results: diff Then I wrote the PowerShell: get-content output.txt | foreach-object { [Int] $_ } | sort-object | out-file -encoding ascii sorted.txt compare-object (get-content output.txt) (get-content sorted.t…

AFAICT, you are just trying to check if a file is sorted? Then wouldn't:

    diff (cat out.txt | sort | out-string) (cat out.txt -raw)
do it?

Re: In defense of PowerShell

#63

The tab completion in powershell is frustrating to me. I never want to cycle through every available option (especially when many PSH commands have literally hundreds of switches). I want the tab-completion to only show options for which I've started typing the prefix. I want double-tab to print a listing of said options so that I can see them all at once. Is this possible? Right now it feels like there's a major lac…

Hm? After typing "xyz -fo" I will get completions beginning "-fo", such as "-foo" and "-foobar", but I won't get completions that don't begin with "-fo".

But yeah, I don't like the cycling, either. I'd also prefer to get a list of the possible completions.

Re: In defense of PowerShell

#64

Earlier quoted context omitted.

What about service apache2 restart

Or /etc/rc.d/apache2 restart, as one would find in the BSD world (and Slackware, with a bit of modification). This isn't to mention that it should be relatively trivial to map "restart-service $foo" to "/etc/rc.d/$foo restart" or "systemctl $foo.service restart" or whatever if one so chooses.

Sure you could write functions or aliases to everything to give them more predictable names. But you shouldn't have to.

Re: In defense of PowerShell

#65
post #15
post #7

I work primarily in a Microsoft environment, although I have Linux shell experience as well, and I totally don't get Powershell. What is a cmdlet? Why does it need a stupid made-up name like that? Why are all the commands incredibly verbose and hard to remember? I avoid using it at every opportunity.

As a Unix person, 'Restart-Service' seems a lot easier to remember than 'systemctl'. Edit: Restart-Service is also easier to remember than /etc/init.d was. Edit 2 (rate limit): `service` on RHEL is great, but it's a Red Hat-ism. Which is fine, I used to work at Red Hat, but still. It's also pretty limited: you use service to start/stop/restart, but you still use systemctl to list services, or list /etc/init.d (techni…

Regarding your edit: service works just fine on ubuntu as well

Re: In defense of PowerShell

#66
post #34

Earlier quoted context omitted.

Some of us do, but we've given up trying to expose HN to the shell. The anti-Microsoft culture that built up in the late 1990s and early 2000s has too much inertia on HN to overcome by occasional articles.

The anti-Microsoft culture that was earned in the late 1990s and early 2000s has too much inertia on HN to overcome by occasional articles. FTFY

I'm glad you pointed out it was earned, it's not as though the anti-Microsoft culture came from thin air

Re: In defense of PowerShell

#67
post #31
post #11

I dislike windows (and by extension, powershell) because a solution such as changing the port the webserver runs on looks something like: New-ItemProperty IIS:\sites\DemoSite -name bindings -value @{protocol="http";bindingInformation=":8081:"} http://www.iis.net/learn/manage/powershell/powershell-snap-i... What did I just modify? Is it persisted to the hard disk? How do i back that up? How do I revert the change? How…

That example you gave is from 2008. You would use the current PowerShell Cmdlets provided for managing IIS. IIS:\>New-WebBinding -Name "Default Web Site" -IPAddress "*" -Port 80 -HostHeader TestSite https://technet.microsoft.com/en-us/library/ee790599.aspx

And THAT is the other thing. bash 7 years ago is the same as bash today, no changes based on some corporate overlords marketing idea of the month. Powershell is still in flux, and with MS as the owner, when will it ever be stable?

Re: In defense of PowerShell

#68
post #66
post #34

Earlier quoted context omitted.

The anti-Microsoft culture that was earned in the late 1990s and early 2000s has too much inertia on HN to overcome by occasional articles. FTFY

I'm glad you pointed out it was earned , it's not as though the anti-Microsoft culture came from thin air

As your emphasizing comment embodies, that culture is still strong, and seems incorrigible. Microsoft are The Unredeemable. Even their current era of open sourcing isn't enough to wash away the sins of the past executives.

On a more topical note, one of the limitations of Powershell is it can only do basic math and (obviously) basic Algebra. To extend this, you can invoke .NET from the command line. Try these:

> $Area = [math]::pi

> $eight = [math]::pow( 2, 3 )

http://www.madwithpowershell.com/2013/10/math-in-powershell....

Re: In defense of PowerShell

#69

Earlier quoted context omitted.

What about service apache2 restart

Or /etc/rc.d/apache2 restart, as one would find in the BSD world (and Slackware, with a bit of modification). This isn't to mention that it should be relatively trivial to map "restart-service $foo" to "/etc/rc.d/$foo restart" or "systemctl $foo.service restart" or whatever if one so chooses.

FreeBSD uses the service command these days too.

Re: In defense of PowerShell

#70
post #31

Earlier quoted context omitted.

That example you gave is from 2008. You would use the current PowerShell Cmdlets provided for managing IIS. IIS:\>New-WebBinding -Name "Default Web Site" -IPAddress "*" -Port 80 -HostHeader TestSite https://technet.microsoft.com/en-us/library/ee790599.aspx

And THAT is the other thing. bash 7 years ago is the same as bash today, no changes based on some corporate overlords marketing idea of the month. Powershell is still in flux, and with MS as the owner, when will it ever be stable?

You're comparing the IIS management command lets to bash. PowerShell the language is largely the same, the same as bash. A more apt comparison would be to apachectl and the apache config files, which have changed.
Post reply on HN