Issue accessing Dashboard built-in variables

hi guys, a question in regards to build-in variables, I have been requested to create a dashboard and logs who is using it, I am having trouble to get the Dashboard built-in variables (especially $User and $RemoteIpAddress) , my code below:

$DebugPreference = 'Continue'
$logfile = "C:\PSULogs\Dashboard\Dashboard.txt"
Start-Transcript -Path $logfile -Append
Write-Debug  "Dashboard Variables: "
foreach ($var in $(Get-PSUVariable)) {
    Write-Debug "$($var.name) : $($var.value)"
}
Write-Debug  "PowerShell environment variables: "
foreach ($var in $(Get-Variable *)) {
    Write-Debug "$($var.name) : $($var.value)"
}

## dashboard scripts here ...

Stop-Transcript

From the above I am not able to get any Dashboard built-in variables. Any suggestion?

Product: PowerShell Universal
Version: 3.5.3
Dashboard Environment: 7.3.0

The variables are available like this…


image

1 Like

Hi Jori, thanks for your quick reply!

Follow up question, how do you access $RemoteIpAddress when you declare $Pages first?
For example:

$Pages = @()
$Pages += New-UDPage -Name 'My Home Page' -Content {}
$Pages += New-UDPage -Name 'Diagnostics' -Content {}
New-UDDashboard -Pages $Pages -Title 'Dashboard'

If I use the New-UDDashboard -Pages then I can’t use -Content{}
What do you suggest?

Thank you

You would use it within the content of the page.

$Pages = @()
$Pages += New-UDPage -Name 'My Home Page' -Content {
$RemoteIpAddress
}
$Pages += New-UDPage -Name 'Diagnostics' -Content {}
New-UDDashboard -Pages $Pages -Title 'Dashboard'