PowerShell: A Better CMD.EXE

Posted by Johan Cyprich on 03 Feb 2009 | Tagged as: Applications

Every systems administrator and power user is very familiar with CMD.EXE: the command line interpreter for Windows. Its used for running applications from the command line, and also for performing administrative tasks with batch files. Not much has changed with the traditional command line interpreter from the days of DOS 1.0. The batch language has improved and more functionality has been added, but its still very limited and not as capable as Linux command shells (i.e. bash).

Taking on Bash

All of this has changed with Microsoft’s PowerShell. This is a vastly improved command line shell with a built-in programming language. The language is very similar in capabilities to PHP or Perl and works very well with creating small utilities for Windows. The big advantage of PowerShell over Linux shells is the vast .NET Framework that it has access to. You can write a script that can extract data from a Microsoft SQL Server database, send it by FTP to a remote folder, and then send an e-mail notifying a user where they can find the files that were transferred. Before this, a batch file would have to call external applications to perform the FTP and e-mail functions.

PowerShell scripting can easily be replaced by any of the Visual Studio .NET languages, but it has the advantage of being able to edit source code and immediately execute it.

Apart from scripting, the shell is also very good for executing commands, or cmdlets as they are called, from the command line. With this, you can perform complex operations that would require a great deal of programming to do.

Choose the Right Version

If you search Microsoft.com, you will find Windows PowerShell 1.0, but I would not recommend using this version. A better choice is the Community Technology Preview version of PowerShell 2.0. This version supports running scripts on a remote machine, creating cmdlets with its scripting language, reusable modules for organizing scripts, a GUI integrated scripting environment, and many more useful features.

Uninstalling PowerShell 1.0

Before you can install PowerShell 2.0, you need to uninstall version 1.0 if you installed it previously. This can be done by checking on the Show updates box in Add or Remove Programs (Control Panel). This is required otherwise Windows PowerShell will not be visible for uninstalling. You can find it in the Windows Software updates section.

image

Is It Worth Learning?

PowerShell is a powerful scripting language and can hold its own again PHP and Perl. The command line interpreter will save you time as a Windows administrator and you won’t go back to CMD.EXE or batch files after learning it. PowerShell is worth the effort in mastering it.



Tweet This Tweet This Post!

Related posts:
    Setting Permissions to Run PowerShell Scripts
    pscoder: PowerShell plugin for Eclipse
    How to Install Windows Server Backup
    Downloading the Standalone Version of SQL Server 2008 Express

Share this post:

del.icio.us:PowerShell: A Better CMD.EXE digg:PowerShell: A Better CMD.EXE spurl:PowerShell: A Better CMD.EXE wists:PowerShell: A Better CMD.EXE simpy:PowerShell: A Better CMD.EXE newsvine:PowerShell: A Better CMD.EXE blinklist:PowerShell: A Better CMD.EXE furl:PowerShell: A Better CMD.EXE reddit:PowerShell: A Better CMD.EXE fark:PowerShell: A Better CMD.EXE blogmarks:PowerShell: A Better CMD.EXE Y!:PowerShell: A Better CMD.EXE smarking:PowerShell: A Better CMD.EXE magnolia:PowerShell: A Better CMD.EXE segnalo:PowerShell: A Better CMD.EXE gifttagging:PowerShell: A Better CMD.EXE

Follow Me:

Did you find this post interesting and useful? You can keep up to date on this blog by subscribing to my RSS feed, or you can have new posts sent to you by e-mail. You can also follow me on Twitter.


6 Responses to “PowerShell: A Better CMD.EXE”

  1. on 04 Feb 2009 at 7:59 am 1.Jeffery Hicks said …

    While PowerShell v2.0 has a wealth of new features it is NOT supported in a production environment. Technically it is not even an alpha product yet and things can change. You won’t waste any time learning PowerShell v1.0 as basic concepts and core cmdlets don’t really change. PowerShell v2.0 simply adds a lot of new stuff to the mix.

    Jeffery Hicks
    Microsoft PowerShell MVP
    http://blog.sapien.com
    follow me: http://www.twitter.com/JeffHicks

    “Those who forget to script are doomed to repeat their work.”

    Now Available: Managing Active Directory With Windows PowerShell: TFM

  2. on 05 Feb 2009 at 1:56 am 2.Anupam Kumar said …

    I downloaded and installed Microsoft’s PowerShell. I found it quit intreasting and useful. It gives a UNIX flavour.

  3. on 06 Feb 2009 at 12:12 pm 3.Johan Cyprich said …

    PowerShell would make Windows more appealing to UNIX systems administrators.

  4. on 07 Feb 2009 at 6:20 pm 4.Johan Cyprich said …

    Jeffery, I learned PowerShell with v1.0 but I decided to use 2.0 for the extra functionality it provided. While its not meant for use in a production environment, I’m using it in one with caution.

    I hope that Microsoft will create a version of PowerShell that runs in Windows 2000 since I’m administering one server which could use the better scripting.

  5. on 08 Feb 2009 at 7:12 am 5.Jeffery Hicks said …

    I needed to make sure your readers didn’t get the impression that Microsoft was offering them a version choice, because they really aren’t. Personally, I wouldn’t take the risk of run pre-pre release software in a production environment.

    And unfortunately, I doubt you will ever see a version of PowerShell supported on Windows 2000, at least not from Microsoft. The features they are adding just can’t be retrofitted to Windows 2000. They have plenty of work just getting PowerShell v2 features to run on Windows XP and Windows 2003.

  6. on 08 Feb 2009 at 12:44 pm 6.Johan Cyprich said …

    PowerShell would be great to replace all of the batch files I’m using on the Windows 2000 site, but I could also write simple apps in C# to do the same thing.

    A great addition to PowerShell would be to have a choice to use any .NET language for scripting. I found examples in C# using Add-Type, but couldn’t get them to work.

Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply

CommentLuv Enabled