Issue with Invoke-UDRedirect

Product: PowerShell Universal
Version: 5.3

Hi There,

I’m encountering a bug with Invoke-UDRedirect in PowerShell Universal version 5.3 and would like to see if anyone else has experienced it.

Scenario:

  • I created a test application with a single if statement.
  • I’m using Windows Authentication, so the $User variable is automatically populated with the username logged in.
  • The code snippet is as follows:
New-UDApp -Content { 
    $staticUsername = "Domain\XYZ"

    if ($user -eq $staticUsername) { 
        Invoke-UDRedirect -Url "/AnotherApp/AnotherPage" 
    }
}

Problem:

  • Two users are required to reproduce the issue.
  • When a user other than the one specified in $staticUsername connects to the dashboard, nothing happens.
  • However, when the user matching $staticUsername connects, this user is redirected to /AnotherApp/AnotherPage as expected. The issue is that the other user in the session is also redirected, which should not be the case.

Has anyone experienced this behavior or have any suggestions on how to resolve it? This bug is causing quite a headache, and any insights would be greatly appreciated.

Thanks in advance!

Not sure, if it’s Working as Designed but if it’s used in a Button, or Dynamic (for non-interactive) it’s Isolated from other Users Session…

New-UDApp -Content { 
    $staticUsername = "Domain\XYZ"

    if ($user -eq $staticUsername) {
            New-UDDynamic -Content {
                Invoke-UDRedirect -Url "/AnotherApp/AnotherPage"
            }
    }
}

The same Problem is also resolved when Show-UDToast shows Up in Connected Sessions. As I understand, PSU runs some Commands “kind of Global” if it’s not in an onClick Event, or isolated.

But it doesn’t work the fast way (like, just use a New-UDDynamic from Start to End of the Page), you need to differentiate between Calling the Commands from an onClick Event and “plain” when the Dashboard Loads / No Interaction is used. For Example the following Code doesn’t work (which makes sense)

New-UDButton -Text "Test" -onClick {
            New-UDDynamic -Content {
                Invoke-UDRedirect -Url "/AnotherApp/AnotherPage"
            }
}

I will mark this answer as Solution, but maybe @adam could explain if it’s WAD or will be changed.

Are you running this app in the Integrated environment or otherwise?

I’m honestly a bit surprised you have to do this. I think it’s a bug but I’d have to try it myself to track it down. Smells like a bug.