What are the advantages of running Powershell instead VBScript?

15,907

Solution 1

VBScript is quite limited in what it can do compared to PowerShell. PowerShell has access to all .NET libraries so you can take advantage of anything you could with a language like C# or VB.NET. You can also load any .NET DLL and take advantage of third party libraries such as those found on codeplex.

PowerShell has some limitations, but you will rarely run into them. Powershell runs on a single thread so if you try to invoke any .NET libraries that create a new thread like BackgroundWorker you will have issues. That said, you can't do any concurrent processing with VBScript. In PowerShell you at least have background jobs.

PowerShell is also interactive. This allows you to try out things at the console first and integrate them into larger more complicated scripts.

There are also a number of free development and debugging tools available for PowerShell. It comes with one actually called the ISE. Another one is available from Quest called PowerGUI. If you want something similar in VBScript you'd have to use something like Visual Studio and launch your script with cscript //X or use something like PrimalScript which is expensive.

PowerShell often allows you to do more with less compared to VBscript. In some cases you can reduce VBscripts that are hundreds of lines to just tens of lines in PowerShell.

If you find yourself reading a BASH script at some point you might be surprised how familiar it is after having picked up PowerShell. The syntax is similar. Also it's easy to convert PowerShell code to C# and visa versa. This is great because if you can't find an example of how to do something directly with PowerShell you just may find an example in C# and it can be converted to PowerShell fairly easily.

Solution 2

Powershell unless you have strong reason not to, simply because that is what Microsoft has designed for the OS and application automation across all its platforms. You may want to read for details in the Microsoft powershell site, though. It has many thing that vbscript wont do or very difficult to do, such as remote execution, security, etc.

Share:
15,907
Diogo
Author by

Diogo

Updated on June 12, 2022

Comments

  • Diogo
    Diogo almost 2 years

    What are the main differences between Powershell and VBScript that would make me choose from one to another when planning a new project with this kind of scripts?

    • Bill K
      Bill K about 10 years
      Awesome question, I really needed to know about this. Absolutely hate some of SO's policies.
    • Kellen Stuart
      Kellen Stuart over 7 years
      This question is constructive...