• powershell and counting lines of code


    i know some people are super excited about powershell...to be frank, i simply haven't looked at enough to make any judgement.  i've sat through a few very high level overview sessions but not enough to get dirty with it.  well, while waiting to present a session with kirk at CA World this past weekend in vegas, i sat in on david's session about powershell.

    immediately upon sitting down i couldn't startup notepad fast enough to start taking notes.  even some of the simple things were very cool to see...here's some of the things i learned in the first 5 minutes...

    want to do a recursive directory listing grouping by file extensions?

    dir -Recurse | group extension

    how about searching a directory for only c# files?

    dir -Include *.cs -Recurse

    okay, what about counting the lines of code within those files?

    (dir -Include *.cs -Recurse | select-string .).Count

    pretty cool i thought!  then i learned about aliasing features within the shell.  now you can create your own "vi" shortcut:

    New-Alias vi notepad2.exe

    nice, now typing "vi" will give me my favorite text editor :-)

    powershell even supports object creation and manipulation...something as simple as:

    $speak = new-object -com "SAPI.SPVOICE"
    $speak.Speak("Hello world")

    using this object creation you can easily script a lot of things relating to your web development setup, including the creation of sites, config files (manipulating config files), etc.

    i learned a lot in those 5 minutes...amazing what you can learn when you get the time to sit down and listen!  enjoy powershell!

    Monday, April 23, 2007 10:12 PM

    PostTypeIcon

Comments.

  • Gravatar
    # Bob On Development » PowerShell in Five Minutes


    Bob On Development » PowerShell in Five Minutes

    4/24/2007 9:21 AM

Your Reply.

  Comment Form  

Fields denoted with a "*" are required.

*Your name:
Subject:
Your blog:
Your email:  (will not be displayed)
*Your message:

 
Please add 1 and 5 and type the answer here: