Custom variable scopes

The custom variable scopes documented at Custom Variable Scopes - PowerShell Universal are not quite clear to me. Except from using Set-PUCache, none of these variables allow for sharing of variables between different dashboards, is this correct?

What is the difference between the $Cache and the $Session variable? The only difference seems to be the $Cache variable is data that can be shared between sessions in the same dashboard as long as the dashboard is not restarted, and the $Session is for the user until the session ends. Am i correct?

The $Page variable is described as Page scope stores variables in per browser tab or window. If a new tab is opened or the current one is closed, the state will be removed.. But it seems that clicking a link that will bring you to a different page in the same dashboard will reset your variable. This seems logical because you will go to another page, but you will not go to another tab. F5 also resets the variable. If both are the case, what is the value of this variable in regards to a normal variable?

All scopes are dashboard specific except Set-PSUCache. Set-PSUCache uses the PSSerializer to store it within the Universal.Server process so any script, dashboard or API can use those values.

$Cache - Specific to the dashboard but shared amongst all users of the dashboard. Can be live objects.
$Session - Specific to the current user’s session and dashboard. Can be live objects. Once the session times out, the data will be removed along with the session. Variables like this can be used across multiple pages and tabs.
$Page - Specific to the current user’s tab (page) and dashboard. Can be live objects. Once the tab is closed or reloaded, this data is invalidated. It will be removed once the session times out.

1 Like