Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages of running Powershell instead VBScript? [closed]

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?

like image 381
Diogo Avatar asked Mar 26 '12 18:03

Diogo


People also ask

Is PowerShell better than VBScript?

VBScript is "lighter" than PowerShell. It utilizes less memory and is generally "faster" than PowerShell at doing the same tasks. However, the time required to code a solution in VBScript is considerably higher than in PowerShell.


1 Answers

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.

like image 82
Andy Arismendi Avatar answered Oct 05 '22 13:10

Andy Arismendi