Converting VBScript's String Function

Definition: Returns a repeating character string of the length specified.

String

The String function provides a quick, reasonably fail-safe way to create a string consisting of a specified number of repeating characters. In other words, a string similar to this:

"===================="

(Yeah, we know. But this is sometimes useful when formatting data for display in a command window.)

If you ever do need to string together 20 equal signs or what-have-you in Windows PowerShell, you can accomplish this task by multiplying (yes, we said multiplying) an equals sign by 20 (strange, but true):

$a = "=" * 20

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

====================

Return to the VBScript to Windows PowerShell home page