views:

997

answers:

7

I played around with PowerShell yesterday, and it seemed pretty nice ( the GUI at least ). Is it worth getting to know the language? I'm pretty proficient in Ruby/Python/Perl/Groovy when it comes to scripting languages, so I think the fact that PowerShell is a scripting language isn't a bonus here.

Another thing I didn't like was that PowerShell can't be made into an exe, and right now, it isn't supported on all Windows computers.

Is it worth learning it? Will that process teach me something I don't already know?

+3  A: 

Learning something new is always good, but in this case, I would suggest learning something more relevant. As a developer, I looked at what PowerShell could do for me, and I didn't see much that I could accomplish through other means just as easily, if not more easily. However, if you like Windows scripting, go for it!

Thomas Owens
I'm interested in what that something more relevant is :)
Geo
this has been my suspicion with PowerShell.
Jweede
More relevant depends on what you do or want to do in the future...
Thomas Owens
In my current job I do all sorts of stuff. I get to choose my language almost every time I have some task, and this makes things interesting. Today I may be implementing a parser, tommorrow I may write a screen scraper.
Geo
In that case, more relevant for you might be a new paradigm (function? aspect-oriented?), a new language that you've wanted to look at but haven't had the time, or brush up on a language you haven't used in a while.
Thomas Owens
If you find yourself writing silly little winforms or console apps to do one tests or tasks, then you could benefit a LOT from powershell.
x0n
x0n: I don't find myself doing that very often...
Thomas Owens
Of course, learning to extend PowerShell with Modules/Snapins would cover two bases, and allow you to start providing administrators with the ability to automate the systems you create.
Richard
+34  A: 

If your job entails administrating Windows or Windows Server then the answer is a definite YES. Most of the new Microsoft server products coming out will be administered via PowerShell - at least from the command line. In most cases there will still be a GUI that layers over top of the PowerShell cmdlets. In fact, this directive is part of Microsoft's Common Engineering Criteria (CEC) for server products.

If you are more of a developer then I would still say YES because I believe it is in every developer's best interest to have mastered a powerful shell (er PowerShell :-)). There are quite a few file system and computer admin tasks we need to perform as developers. PowerShell can really help make you more productive at this stuff especially with it's great support for XML and WMI. Want to load up an XML doc as a .NET System.Xml.XmlDocument object? It is as easy as this:

[xml]$xmlDoc = Get-Content web.config

You mentioned screen scraping. This is pretty simple with PowerShell with its strong regex support. You can also couple that with the XML support to process RSS easily e.g.:

$url = "http://blogs.msdn.com/powershell/rss.xml"
[xml]$xml = (new-object System.Net.WebClient).DownloadString($url)
$xml.rss.channel | Foreach {$_.item} |
    Where {[DateTime]$_.pubDate -gt (Get-Date).AddMonths(-1)} |
    Format-Table Title

Let me add that I am developer doing mostly .NET/C# work on a daily basis. I still find PowerShell useful for several things:

  • Experimenting with .NET right from the command prompt. I think of PowerShell as a .NET REPL. I no longer need to create ConsoleApplication42 to test out some .NET object or API.
  • Launching EXEs and performing file system oriented operations are much, much easier to script in a shell than to code in C# using Process.Start(), FileInfo and friends.
  • Slicing and dicing XML is quite a bit easier in PowerShell than the equivalent C# code. If I were writing a commercial app, then yeah I would do it in C#. But if I need a one-off solution I would use PowerShell. In fact, recently I wrote a simple PowerShell script to do mass modifications to ~260 VC++ project files. Doing that by hand would have sucked!

Check out Scott Hanselman's 2009 Ultimate Developer & Power Users Tool List - notice that PowerShell is in the big ten life and work-changing utilities!! Amen, brother. Amen. :-)

BTW if you are just dipping your toes in the PowerShell waters be sure to check out these free resources. I have an ~50 page free eBook called Effective Windows PowerShell which will give a good mental model for how PowerShell works. Dr. Tobias Weltner also has a free book online called Mastering PowerShell. If you ever get to the point you want to spend money the definitive book is Windows PowerShell in Action.

Keith Hill
I think your post ended too early.
Geo
I downloaded your ebook now, I think it's going to be interesting.
Geo
Yeah, not sure what happened. Think I hit tab too many times. It's done - for now. :-)
Keith Hill
+6  A: 
OscarRyz
+3  A: 

I love PowerShell. Anytime you have to do file or registry manipulation, it's far and away better than cmd, and even most other scripting languages. It's also the basis for lots of new functionality in Windows 7/Windows 2008 R2 (like managing Active Directory) and the core managemnt for Exchange 2007 - and you never know when you might need to do that.

Not all development work is application deevelopment, after all.

For pure development stuff, check out psake - a nifty build tool built in PowerShell.

Jeff Hardy
+11  A: 

For a developer, messing with the shell is a normal course of work - ask any Unix dev. Unfortunately, this culture is mostly missing from Windows, for the lack of good properly integrated shells - and PowerShell was designed to change just that. If you live inside your IDE all the time, then you probably don't really need it (but then you don't know what you're truly missing). If you already find yourself working in command prompt quite a lot, then PowerShell is definitely a very worthwhile learning investment.

That said, don't treat it as a general-purpose "scripting" language along the lines of Python or Ruby. That will get you nowhere. PowerShell is a shell language, just as bash or csh are - a DSL designed for a very specific subset of tasks - working with files (and, in case of PS generalized virtual FS) and processes, gluing them together. If you deal with those kinds of tasks regularly, learn it. If you do not, forget it.

Pavel Minaev
Pavel, all very excellent points!
Keith Hill
While it may not be a general-purpose scripting language I noticed that it does that job pretty well too. Especially the object-based pipeline is a very effective tool in creating elegant scripts that do specific tasks—and those need not be purely VFS-based.
Joey
Great Post. +1 I am like the ORiley Pocket Rererence Windows PowerSHell by Lee Holmes
Peter Walke
+1  A: 

The thought of learning something new is something I relish, but now when it comes to Microsoft language. If you already know Python/Perl/Ruby and other scripting languages, then there's no need in my opinion, to waste your time on something you might never use.

Again, this is a Microsoft based platform, so you may get varied answers.

Helen Neely
+3  A: 

PowerShell is definitely worth picking up and kicking the tires on and getting a handle on the basics. Here is a video of Jeffrey Snover talking about Integrated Lifetime Earnings and how this is affected by PowerShell.

Here is another video snippet of How to Host [and automate] PowerShell in a WPF Application

Doug Finke