Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the benefits of a Powershell script over a Console Application?

For some of monitoring applications and for tasks that are required to be scheduled to poll some service, we traditionally use a console application that in turn calls some methods in our business layer or polls file locations/ftp locations.

For another task I was carrying out I started playing about with Powershell and was pretty impressed, which got me thinking what are the benefits of a Powershell script and a console application.

Is seems the fact that the powershell script can be edited on the fly without recompiling which makes it a plus for potential changes, but there must be drawbacks that I am not seeing.

So when would people advise swapping a console application for a Powershell script?

like image 776
Dean Avatar asked Jul 22 '09 17:07

Dean


2 Answers

You should also consider the size of the "app". If a single, smallish file can manage the task, then PowerShell is a great solution. Once you get beyond that, then you need to ask questions about the maintainability and understandability of the script vs. typical application code. (And source control shouldn't enter the equation since both should be stored there!)

like image 97
John Fisher Avatar answered Oct 13 '22 01:10

John Fisher


I think the better way to think of this is, when would you choose a console application?

If you're not concerned about bleeding-edge run-time speed, distribution to third parties (PowerShell isn't quite standard yet), or protecting source code then I think PowerShell is a strong contender.

By the way, PowerShell can manipulate COM objects out-of-the-box so in terms of task-automation it works quite well as glue-code between .NET and COM-based infrastructure.

like image 27
hythlodayr Avatar answered Oct 13 '22 01:10

hythlodayr