September 15th, 2015

PowerTip: Get First 140 Characters from String with PowerShell

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to retrieve the first 140 characters from a string.

Hey, Scripting Guy! Question How can I use Windows PowerShell to retrieve the first 140 characters from a string?

Hey, Scripting Guy! Answer Use the SubString method from a string. Specify the starting point (in this case 0) and the
           number of characters to retrieve (in this case 140). The following example assumes that $a 
           contains a string with more than 140 characters:

$a.SubString(0,140)

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.