I have a PowerShell script that connects to a localhost API that returns a dictionary of "sessions" and whether they are active
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$response = Invoke-RestMethod 'https://localhost:44356/api/RDM/getSessions' -Method 'GET' -Headers $headers
$numOfUsers = Invoke-RestMethod 'https://localhost:44356/api/RDM/countSessions' -Method 'GET' -Headers $headers
for($x = 0; $x -lt $numOfUsers; $x++)
{
$user = $response.userId[$x]
$name = $response.sessionName[$x]
"`nSession Name: $name"
"User Logged In: $user`n"
}
pause
When more than one session is active it returns correctly:
Session Name: ExampleSession
User Logged In: ExampleUser
But when only 1 is active it returns only the first letter:
Session Name: E
User Logged In: E
I do know that this bug is caused by the script and not the API, however so far I am unable to find the source of the problem.