In Windows PowerShell, you can perform a substring operation using the SubString() method.
Let's take a look at a few examples.
Example 1: One-Liner SubString
echo "Welcome to Code2care!".SubString(11)
Output:
echo "Welcome to Code2care!".SubString(0,7)
Output:
Example 2: SubString with Script
$string = "PowerShell is Fun!"
$substring = $string.SubString(0,10)
echo $substring

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!