Getting the last 108 characters via. invoke-restmethod

Hi there fellas!

I am having some difficulties modifiying this script to get last 200 characters of whatever it scans.
I have no issues with getting the first 200 or so, but finding the variable length of the scanned file, and only giving me the last 108 characters seems to be difficult.

Can anyone point me in the right direction? :slight_smile:

The current script:
https://gist.github.com/jtn-webkoncept/53c90738d84eb8cb712e3ded4f7914ec

# Sample 200 character string
Remove-Variable invoker -EA 0 
0..9 | foreach { $Digit = $_; 0..19 | foreach { $invoker += [String]$Digit } }

# finding the variable length of the scanned file, 
$invoker.Length 

# only giving me the last 108 characters seems 
$DesiredLength = 108
if ($invoker.Length -ge $DesiredLength) {
    $cutcontent = $invoker.Substring(($invoker.Length - $DesiredLength),$DesiredLength)
} else {
    "Error: 'invoker' string length is less than '$DesiredLength'"
    # or
    # $cutcontent = $invoker
}

not sure If I understood the question properly. If you are looking for something to get last 200 chars from a string.

$String = 'a long String here'
$String[($String.Length - 200),($String.Length)]