Search This Blog

Thursday, December 8, 2011

Powershell goodies

I posted a blog last time about my attempt to learn PowerShell again and I found that it is quite interesting to learn this new scripting language on Windows. Yes, there are many scripting languages available on other platforms but on Windows none of them really works great in my opinion not because they are bad but because they are not really meant for Windows. I guess we can argue about that all day but in any case I would like show another way to increase your PowerShell knowledge. That is PowerShell Code Repository! This web site has many many interesting scripts that can be used right away.

For instance, for years every time I wanted to list only directories in my current location, I had to search online to figure out how to do it or run 'dir | more' and look for myself. Then, as I began to learn PowerShell, I found that I can do this with 'dir | where-object { $_.psiscontainer -eq '$true' }' but that is too long to type.
Then I found a script that will reduce my keyboard typing effort. That is 'Compare-Property' function from PowerShell Code Repository. With this function, I can do the same task in the following manner.


PS >Set-Alias ?? Compare-Property
PS >dir | ?? PsIsContainer

Pretty cool. So all you have to do is to go the site and see if you have any scripts that you want to use. Then download them and keep them in one specific folder. After that, include that folder in your $profile as follows.

$env:path = $env:path + ";c:\scripts"

Once you do that, you can just use script name 'Compare-Property' like the above example as if it is regular PowerShell regular cmdlets. So that's all for now and happy PowerShell!

2 comments:

  1. Fast search engine Checklist for Blogs When creating a blog first,
    the author might have an idea about the market.
    Businesses of any size have the opportunity to include you links when posting an article.

    The title above this hub, is helpful and friendly to search engines and as
    a result of this update. Google must do pretty well selling these ads because Forbes
    estimates the value of their company at $220 billion. I instantly became one of those
    ubiquitous" lifestyle" experts.

    Also visit my webpage - affordable search engine placement

    ReplyDelete
  2. This is achieved through the Best Body Cleansing Dietifying nature of the food plan.
    Monday 8th AprilI started the day with a bowl of fresh
    fruit, fresh greens and dried fruits.

    My homepage homepage

    ReplyDelete