Search code examples
windowspowershelldos

Migrating from cmd.exe to PowerShell or using PowerShell in place of other tool. When is it better to use PowerShell?


I have been contemplating moving forward from using the cmd.exe command line program which provides a command line interface and a batch programming environment that extends the one available using the old command.com program on the old DOS operating system. The cmd.exe program has been available on Windows system for a very long time. However, I feel that it has its limitations in terms of usability and flexibility.

I have heard that PowerShell can be used to manage various Microsoft products, and also supports snap-in modules for third-party vendors, supports several very useful programming constructs such as pipelines, and above all is tightly integrated with the .NET framework, which of course makes the PowerShell programming language very powerful.

Perhaps this question is somewhat broad, but in view of the existence of several alternative programming environments such as Python and Perl which are used for system administration (these in many ways have slowly replaced shell scripts on Unix systems for more complex tasks quite some time ago), I was wondering where PowerShell fits into the ecosystem, and above all whether it is worth learning, and especially if it is worth learning when someone already knows a tool such as Python or Perl which is also used for system administration. Is PowerShell more of a system administration tool, or is it a more general programming tool that does not require compilation, unlike, say, C#?

What I can see as advantages is that it comes preinstalled, and that you can invoke .NET API functions from within it.

If anyone can sort out a few scenarios demanding that it be learned, especially in the case where other programming tools are already known, I would appreciate it. In particular I would like to know, besides quick .NET scripting, what sort of tasks are generally speaking more suitable to PowerShell programming.

Thanks.


Solution

  • The number one reason to use Powershell is that Microsoft is starting to push all it's product management tools to PowerShell. In fact, when working with things like Exchange, there are some things you can only accomplish with powershell anymore.

    The second reason is that powershell is a full scripting language, dos batch command language is not.

    The third reason, is that anything that is possible in .Net is possible in PowerShell (sometimes with a bit more work, sometimes with a bit less).

    Also, there are some companies, like VMware that the only command line based interface released for their products is via a powershell snap in or module.

    And, in my humble opinion, it is a pretty fun environment to work in.