As I commented earlier, I have no way to test against your site and I have no way to know what the correct call sequence should be.
Your image shows 2 errors which appear to come from line 66. But I don't know what happened prior to that. Did the invoke commands on lines 54 and 55 work?
Since the call is in a function, in order to update the $lp varianble, I believe that you will need to refer to the variable like this.
$reply = Invoke-WebRequest -Uri $requestUri -WebSession $script:lp -Body $Login
For your initial testing, don't use the Get-SubUrlResponse function. Just do one "suburl" inline with login call. Get that to work first.
And this section doesn't make sense to me.
$reply = Invoke-WebRequest -Uri $requestUri -WebSession $lp -Body $Login
Write-Host "$($i) attempt = Request $($requestUri) "
if ($reply.StatusCode -eq 200)
{
Write-Host "$($i) attempt = Request StatusCode: $($reply.StatusCode), done!" -ForegroundColor DarkGreen
break;
# track execution time:
$timeTaken = Measure-Command -Expression { $site = Invoke-WebRequest -Uri $requestUri}
$milliseconds = $timeTaken.TotalMilliseconds
$milliseconds = [Math]::Round($milliseconds, 1)
"This took $milliseconds ms to execute"
If the Invoke-WebRequest works (200), you turn around and measure a second Invoke-WebRequest. Why? If you are interested in how long a request took, wouldn't you want to measure the first request?