PS: Fetching substring

A quick code to fetch the substring of a given string

 

Code:

$UserName         = "TestUser009"
$UserNumber       = $UserName.substring($UserName.length-2)
Write-Host $UserNumber

Output:

09

Leave a Reply

Your email address will not be published. Required fields are marked *