PowerTip: Use PowerShell to Multiply Strings

PowerTip: Use PowerShell to Multiply Strings

  • Comments 3
  • Likes

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

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • I'll see you and raise you two dogs.

    "cat " *5 + "dog "*2

  • @JRV too funny!

  • @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.