PowerShell SubString with Examples

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)



    echo "Welcome to Code2care!".SubString(0,7)



Example 2: SubString with Script

    $string = "PowerShell is Fun!"
    $substring = $string.SubString(0,10)
    echo $substring

    PS> ./powershell-script.ps1

PowerShell SubString Example

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap