You can just do this.
"=" * 20
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi I am having issues translating a vbScript to powershell. The purpose is to generate a line of chars to improve the readability of the script output. This is done in vbScript by use of the function string(), where I can generate a string of similar chars i.e. wscript.Echo String(20,"=") gives me: "====================" Can powershell generate something like this in a simple way? Br Peter
You can just do this.
"=" * 20
If you're looking for a more direct replacement for that:
[string]::new("=",20)
But the answer from @MotoX80 is more intuitive (once you get past the "how does the string class perform multiplication?" puzzle!).
Depending on your proclivity for diversity, you can also use "".PadRight("=",20)
or "".PadLeft("=",20)
. :-)