Converting VBScript's FormatCurrency Function

Definition: Returns an expression formatted as a currency value using the currency symbol defined in the system Control Panel.

FormatCurrency

To format a Windows PowerShell value as currency you simply use the .NET Framework formatting commands. The following two commands assign the value 1000 to the variable $a, then use the currency formatting string “{0:C}” to format the value as currency (note that the value to be formatted is included as part of the -f parameter):

$a = 1000
$a = "{0:C}" -f $a

When you run this command and then echo back the value of $a you should get the following:

$1,000.00

Return to the VBScript to Windows PowerShell home page