Using buttons to return array of data to another button

Not sure if this is a more advanced area or not. I have a dashboard where I have 2 button’s and a code display. The idea I had was “button1” runs a script and returns data in a list object such as @{Column1=“data1”;Column2=“data2”;Column3=“data3”}. to the main dashboard script so that when “button2” is pressed, I can use the data values from “button1” to populate the variables needed to generate the connection string that when pressed button2 opens up in a new tab?

I understand it might be a little confusing, but essentially “button1” gathers me all the data and connects into the system and does the job. “button2” then allows me to give the user a “remote link” to the system when pressed and allows them to access it.

I’ve tried using Set-Variable, Get-Variable etc… But everything I try doesn’t work. The dataset returns correctly and I’m able to view it in the script output, but past that it doesn’t seem to be working? Any ideas on how something like this could be done?

Product: PowerShell Universal
Version: 3.0.3

It is a pb of scope maybe ?

To access variables between two endpoints you can use $session or $cache variables.