Multi-Session Dashboard - New-UDToast message seen by multiple users

I am trying to display a message using New-UDToast when user connects to a server.
Test-Connection -ComputerName $servername -Quiet -Count 1

If $true it will broadcast a message “Successfully connected”. If $false “connection failed”.

When I tried to use in on 2 computers one have a valid server and other have an invalid server.
I clicked the button to on both computers simultaneously both computers got both message, one is “Successfully connected” and the other “connection failed”.

Is there a way to just show the New-UDToast to a specific user?

Hello @RATG I reported this as a bug a little while back…I think it was something to do with using an -endpoint within the modal, once I removed that problem went away…let me see if I can find the official bug link…

Looks like this was fixed in the latest build…can you please state version you are using and if it is professional or communty edition. Thanks

Im using professional edition.
Version Name Repository Description

2.7.0 UniversalDashboard PSGallery Cross-platform module for developing websites and REST APIs.

I will wait for the link of the bug that you mentioned so that I can compare it with my code.

Can you upgrade to 2.8? It was just released to the gallery. It should fix this issue.

1 Like

Hi Adam,

I upgraded to 2.8 but still having same issue.

Below is a sample code that I simultaneously run on separate machines.
One would machine would have values on the other would have no values entered.
Both machine would see the message.

What is the best way to code this so that the message will only be visible on a specific session/user?

New-UDTextbox -Type text -Placeholder “Username” -Id “txt_psusername”
New-UDTextbox -Type password -Placeholder “Password” -Id “txt_pspassword”

New-UDButton -Id “btnCredentials” -Text “Connect to Server” -OnClick {
$Session:psusername = (Get-UDElement -Id “txt_psusername”).Attributes[“value”]
$Session:pspassword = (Get-UDElement -Id “txt_pspassword”).Attributes[“value”]

if (($Session:psusername -eq $null) -or ($Session:pspassword -eq $null) -or ($Session:psusername -eq “”) -or ($Session:pspassword -eq “”))
{Show-UDToast -Broadcast “Please enter username/password.” -Duration 2000 -BackgroundColor “Red” -MessageColor “White”}
{Show-UDToast -Broadcast “You entered a username/password.” -Duration 2000 -BackgroundColor “Red” -MessageColor “White”}

You need to remove the -Broadcast flag from Show-UDToast. When you use broadcast, it sends to all connected machines.

User error.
That fixed it.
Thank you so much Adam.

1 Like