Half-Blood Programmer

Product Review: First Look At PowerShell

Last Friday I needed to write a batch file that executes a command several times. I failed because I never fell in love with the syntax. As a guy who started to use PC in Windows 95 and to program in Delphi 7, I always find command lines hard to use and memorize.

But today, after trying PowerShell, I found it much easier to learn than cmd.exe. And writing a for loop is similar to C# language.

for ($i = 0; $ -lt 5; $i++)

But I still wonder why not create something like C# script?

(Updated: It is wonderful that I can do the old Command Prompt stuffs inside PowerShell 1.0. Thus I give up Command Prompt from now on.
Because there is a Command Prompt feature in CBC, I think I can enhance it on systems with PowerShell installed.)
Be Sociable, Share!

One thought on “Product Review: First Look At PowerShell

  1. Anonymous

    > But I still wonder why not create something like C# script?

    Bruce Payette addresses this topic in detail in his book “PowerShell in Action”. Basically the issue is that C#, as-is, would be very difficult as an interactive syntax. PowerShell syntax is designed first and foremost to work in interactive environments. That is the reason why you can’t have forward references in scripts. e.g.

    foo a
    function foo {…}

    With PowerShell, you can always cut and paste a script into an interactive shell session.

    Bruce’s book as the rest of the story if you are interested.

    Jeffrey Snover [MSFT]
    Windows Management Partner Architect
    Visit the Windows PowerShell Team blog at: http://blogs.msdn.com/PowerShell
    Visit the Windows PowerShell ScriptCenter at: http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx