Coffeehouse Post

Single Post Permalink

View Thread: What do you use Powershell for?
  • User profile image

    wkempf said:

    Vs. bat files, it provides a much richer API. A lot of things that can barely be achieved with a bat file by an expert can be trivially implemented in a PowerShell script.


    Vs. VBA scripts, it provides an imediate mode, or shell. Comparing PS to these two isn't as "apples to apples" as comparing it to BASH/CSH/etc (comparing it to BAT I suppose is comparing it to CMD which is "apples to apples", but CMD isn't in the same league as the others).


    Other noteworthy reasons why PS is worth learning:


    1. It can fully utilize .NET libraries. This means there's very little you can't accomplish within PS rather easily, whereas in batch files you'd be SOL and in VBA you'd often be stuck looking for a COM component.


    2. It works with object streams rather than text streams, which is much less fragile and a lot more powerful.


    3. Many enterprise systems, such as Exchange, are moving towards PS management interfaces rather than COM interfaces. IOW, it's getting to be more and more difficult to manage these systems using BAT and VBA scripts.


    4. The shell is a much nicer command line environment in comparison to CMD. Live in it for a while and you'll never go back to CMD.


    5. PS provides a very powerful command line parsing infrastructure and help system, usable from your own scripts. This vastly improves the quality of your scripts with little effort.


    If I thought about it some more, I could come up with other reasons. PS is a game changer. It's got its own set of problems, some of them quite annoying, but overall it's the best shell and scripting environment I've ever used.

    hmmm... number 3 will probably be my reason to get into it if any.


    i guess i've been doing it "wrong" by just writing little console apps (full .net api, full flexibility, error logging) and kicking them off via cmd with arguments, sql job or scheduler.