Using New-UDInput to start a new dashboard

Greetings,

I have created a dashboard from which I want to publish a second dashboard
I am using New-UDInput to capture a server name and write it to a text file in the Script folder. From there, I want to start a new Dashboard that will use the content of the text file as it’s input.

The code for the Input dashboard is:

Import-Module UniversalDashboard

Get-UDDashboard | Stop-UDDashboard

$Root = $PSScriptRoot
$Init = New-UDEndpointInitialization -Variable “Root”

$Input = New-UDDashboard -Title “Inputs” -Content {
New-UDInput -Title “Input” -EndPoint {
param(
[String]$InputField
)

     $InputField | Out-File (Join-Path $Root "Server.txt")

     }
     
     
} -EndpointInitialization $Init

Start-UDDashboard -Dashboard $Input -Port 10002 -AutoReload

Here is the code That takes the content and runs another dashboard:

#Set the script Path
if (Test-Path Variable:Global:PsIse)
{
$ScriptDir = Read-Host “ISE Detected, please enter the directory in which the script resides”
}
else
{
$ScriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
}

#Load Universal Dashboard cmdlets
Import-Module -Name UniversalDashboard

#Capture the Target Server Name
$Server = Get-Content $Scriptdir\server.txt
#$Server = “*********************”
$Sopsys = Get-WMIObject -Class Win32_OperatingSystem -ComputerName $Server
$CompSys = Get-WmiObject -Class Win32_computersystem -ComputerName $Server
$Mem = $CompSys.TotalPhysicalMemory/1GB
$MemGB = [math]::Round($Mem, 1)
$NumProc = $CompSys.NumberOfProcessors
$Man = $Compsys.Manufacturer
$Mod = $CompSys.Model
$Sname = $CompSys.Name
$Sdata = @([PsCustomObject]@{Memory_GB ="$MemGb";Number_Of_Processors="$NumProc";Manufacturer="$Man";Model=$Mod})
$SFeature = Get-WmiObject -Class Win32_ServerFeature -ComputerName $Server | Select-Object Name
$SSftwr = Get-WmiObject -Class Win32_Product | Select-Object Name, Version, Vendor
#Define pages of Multi-Page Dashboard

$Page1 = New-UDPage -Name “General Information” -Icon home -Content {

New-UDCard -Title "Server Name" -Content { $Sname } -FontColor "#ffe4b5" -BackGroundColor "#644a76" 
New-UDGrid -Title "Operating System Version" -Headers @("Product","Build Number","SP Major","SP Minor") -Properties @("Caption","BuildNumber","ServicePackMajorVersion","ServicePackMinorVersion") -Endpoint {$SopSys | Select-Object Caption, BuildNumber, ServicePackMajorVersion, ServicePackMinorVersion | Out-UDGridData } -FontColor "Green"
New-UDGrid -Title "Server Information" -Headers @("Memory_GB","Number_Of_Processors","Manufacturer","Model") -Properties @("Memory_GB","Number_Of_Processors","Manufacturer","Model") -EndPoint { $Sdata | Out-UDGridData }
#New-UDGrid -Title "Installed Features" -Headers @("Installed_Features") -Properties @("Installed_Features") -Endpoint { $SFeature | Out-UDGridData } -FontColor Black


}

$Page2 = New-UDPage -Name “Features and Software” -Icon windows -Content {
New-UDGrid -Title “Installed Features” -Headers @(“Installed_Features”) -Properties @(“Installed_Features”) -Endpoint { SFeature | ForEach-Object {[PSCustomObject]@{Installed_Features = .Name.ToString()}} | Out-UDGridData } -FontColor Black
New-UDGrid -Title “Installed Software” -Headers @(“App_Name”,“Version”,“Vendor”) -Properties @(“App_Name”,“Version”,“Vendor”) -EndPoint { SSftwr | ForEach-Object {[PsCustomObject]@{App_Name =
.Name.ToString().Trim() ; Version = _.Version.ToString() ; Vendor = _.Vendor.ToString() }} | Out-UDGridData }
}

Replace $Dashboard with the desired name of the dashboard

$Test_1 = New-UDDashboard -Pages @($Page1,$Page2)

Replace $Dashboard with the desired name of the dashboard and select a port of your choice

Start-UDDashboard -Port 1000 -Dashboard $Test_1

What I am trying to figure out is how to start dashboard 2 from dashboard 1.

The text file is not populated until you run the dashboard and type some input, so I need to read the text file after hitting submit and use the content to start another dashboard. I have tried several different ways, but have thus far been unsuccessful.

The logic is:

  1. Capture a server name
  2. Write the server name to a text file
  3. Run a second Dashboard that reads the content (servers name) from the text file and populates a variable
  4. Build a dashboard to gather information about the server listed in the variable and publish it.

I just started playing around with UDDash, so I’m a bit green. Any suggestions would be appreciated.

Thanks

Larry

I’m not sure if that’s possible.

I would have a page with a textbox and button at the top, followed by two elements.
The endpoints for each element try to connect to the server named in the textbox. If successful, they build and display their respective grids.
The -OnClick scriptblock on the button (labeled “Load server data” or whatever) runs Sync-UDElement against the two elements, making them reload, presumably for a newly entered server name.

Thanks,
Tim Curwick