powershell and counting lines of code
| Comments- | Posted in
- david aiken
- daiken
- powershell
- scripting
- shell
- command shell
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!
Please enjoy some of these other recent posts...
Comments