Converting VBScript's Dim Statement

Definition: Declares variables and allocates storage space.


In VBScript the Dim statement is used to declare a variable, typically without assigning that variable a value of any kind. To declare a variable in Windows PowerShell, but without assigning a value to the variable, use a command similar to this:

$a = [string]

This command creates a new, empty string variable named $a. In order to declare a variable without assigning it a value you must specify a data type (although this data type can later be changed).

Return to the VBScript to Windows PowerShell home page