April 19th, 2015

PowerTip: Return Specific Number of Letters from String

Doctor Scripto
Scripter

Summary: Use Windows PowerShell to return a specific number of letters from a string.

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

Hey, Scripting Guy! Answer Use the SubString method from a string, and then specify the starting the position and the number
           of letters to return, for example:

PS C:\> ("string").Substring(0,2)

st

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.