PowerShell, Scripting
comments 4

ConvertTo-PowerShell: PowerShell versus “other” scripting examples – Part 1

On the scripting guys forum and various other places, I still see various people asking for VBScript examples or DOS batch file examples for achieving various things on Windows OS. I — almost every time (unintentionally) — provided a PowerShell example even when the person’s preference was VBScript or DOS batch. I see many people shying away from Windows PowerShell thinking that the language is too complex. It is actually not “so” complex. I agree that it takes time to get used to it. 

Windows PowerShell is not just an alternative to other scripting languages on Windows platform. If you think it is, time for you to change that thought process. In my opinion, being an alternative scripting language is a good side-effect of being the most powerful scripting platform. It is time people start using PowerShell or convert to the religion called PowerShell-ism. 

One way to showcase the power of PowerShell is to show how easy it is to script it PowerShell and show how concise these scripts can be. So, that is the goal of this blog series. There is no regular frequency as such for this series. I will take several VB / DOS Scripting examples, convert them to PowerShell and post both versions here. So, it is an on-going process. I will|may not go in to the details of explaing the script in these posts. There is a nice guide on TechNet that talks about converting VBScript to Windows PowerShell.  

To start with, here is something I posted (and @alexandair refined it) on the scripting guys forum. All this script does is to export previous days events from the application event log to a CSV file. 

 VBScript 

PowerShell one-liner 

This is it. Next time, we will see some other script and convert it to PowerShell (a one-liner, if possible).

Filed under: PowerShell, Scripting

by

Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.