Share via


The VBScript-to-Windows PowerShell Conversion Guide

VBScript to Windows PowerShell

One of the cornerstones of education is the concept of scaffolding: the idea that it is easier to learn something new if you relate your new knowledge to, and build upon, existing knowledge. This idea holds true when it comes to learning Windows PowerShell. Yes, Windows PowerShell is different than VBScript, sometimes dramatically different. However, the underlying concepts between the two are often exactly the same: an If statement allows you to take alternate routes depending on a specified condition; an uppercase a is still an A; a constant remains a value that cannot be changed during the running of a script. If you're familiar with VBScript you actually have a head-start over people who know nothing about scripting or programming. After all, you already understand many of the basic concepts.

Hence this guide to translating VBScript to Windows PowerShell. We should point out that this is not intended to be a “word-for-word” translation guide; for better or worse, things don’t quite work that way. Instead, it’s designed to act as a reference guide as you begin writing your first Windows PowerShell scripts. After all, sooner or later you’re bound to run into a situation where you find yourself thinking, "OK, I need to use a Select Case statement here. I know how to do that in VBScript, but how do I do that in Windows PowerShell?” That’s where this guide can come in handy; it takes all the VBScript functions, statements, and operators and shows you, as much as possible, a Windows PowerShell equivalent.

Incidentally, we tried to find an equivalent for most of the commands listed in this Translation Guide; however, we would never claim that we found the best equivalent for these commands. If you know of a better/faster/easier way to, say, format a number as currency in Windows PowerShell, please let us know. We’ll publish these alternate approaches as an addendum to this guide.

Download this conversion guide as a Word document (along with Windows PowerShell Week sample scripts). Right now this includes only the VBScript commands. We’ll be adding a download soon that includes the Scripting Runtime objects and WSH.

Top of page Top of page