PowerTip: Use PowerShell to Multiply Strings


Summary: Use Windows PowerShell to multiply strings.

Hey, Scripting Guy! Question How can I use Windows PowerShell to display a string a number of times, without doing a lot of typing?

Hey, Scripting Guy! Answer Multiply the string:

PS C:\> "cat " *5

cat cat cat cat cat

Comments (3)

  1. jrv says:

    I'll see you and raise you two dogs.

    "cat " *5 + "dog "*2

  2. jrv says:

    @Ed – but rabbits are even better at multiplying;)

    I get such a kick out of the silly things in PowerShell like being able to do math on strings.

  3. Ed Wilson says:

    @JRV too funny!

Skip to main content