Action()
{
    int HttpRetCode=0;
 
    // Set redirection depth to 0
    web_set_option("MaxRedirectionDepth", "0", LAST);
 
    // Initial Location where we want to go
    lr_save_string("http://www.mercury.com", "Location");
 
    do
    {
        // Save new Redirection Info (Location: header)
        web_reg_save_param("Location",
                           "LB=Location: ",
                           "RB=\r\n",
                           "Ord=1",
                           "NotFound=Warning",
                           "Search=Headers",
                           LAST );
 
        // do any web call (This needs to be modified to suit your needs)
        web_url("my_req",
          "URL={Location}",
          LAST );
 
        // Get HTTP response Code
        HttpRetCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
 
    } while ((HttpRetCode>=300) & (HttpRetCode<400));
 
    return 0;
}
$y=0; $c=100; $d=10; for($x=0; $x -lt 10; $x++) { $y++; $a=$y; $y=($y-1)+$c; $b=$y;  
bin\mdrv.exe -usr "script_name.usr" -waittime $d -rowsmin $a -rowsmax $b }
web_set_rts_key("key=HttpErrorsAsWarnings", "Value=1", LAST);
https://www.youtube.com/watch?v=ZscWpd8LbI8
 #[xml]$adrt = .\lreapi_get_all_tests.ps1
($adrt.Tests.Test | Where-Object Name -eq 'STORM_TEST_INTEGRATION' | Where-Object TestFolderPath -eq 'Subject\OneMDSR3A').ID
$user = 'c977004'
$pass = $env:password
$pair = "$($user):$($pass)"

$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)

#Write-output $base64

$headers = @{
    'Authorization'= "Basic "+$base64
 }

#Write-Output $headers


$response = Invoke-WebRequest -Uri https://lreserver/LoadTest/rest/authentication-point/authenticate -Method GET -Headers $headers -SessionVariable session

foreach ($ck in $response.BaseResponse.Cookies) { 
    if($ck.Name -eq "LWSSO_COOKIE_KEY") {
    
         
        $cookiereq = $ck.Value 
    }
}


$TCSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession
$cookie = New-Object System.Net.Cookie 

$cookie.Name = "LWSSO_COOKIE_KEY"
$cookie.Value = $cookiereq

$TCSession.Cookies.Add('https://lreserver', $cookie)
#$TCSession.Headers.Add('Content-Type', 'application/zip')
$TCSession.Headers.Add('Content-Type', 'application/xml')
#$TCSession.Headers.Add('Content-Disposition', 'attachment; filename=Reports.zip')

$response2 = Invoke-WebRequest -Uri https://lreserver/LoadTest/rest/domains/BSC/projects/EU_oneMDS_PerformanceTesting/tests -Method GET -WebSession $TCSession 
write-output $response2.Content 
GoBack