Dashboard with Multiple Pages as Different Files

I’m not sure if I’m doing something wrong or if this is a bug. I’m attempting to create a dashboard with multiple pages using specific files located in C:\ProgramData\UniversalAutomation\Repository\TestDashboard\

I have 3 files:

  • Home.ps1
  • File1.ps1
  • File2.ps1

In my Home.ps1 file is wrote the following:

$UDScriptRoot = $PSScriptRoot
$Pages = @()
$Pages += New-UDPage -Name ‘File One’ -Content {
. “$PSScriptRoot\File1.ps1”

$Pages += New-UDPage -Name ‘File Two’ -Content {
. “$PSScriptRoot\File2.ps1”

New-UDDashboard -Title ‘Home’ -Pages $Pages

Am I supposed to add anything to the files that will be used as the pages? Where do I write the CSS code that FIle1 and File 2 need? Does it still go in each individual file or can I add it to the Home file and add

. (Join-Path $UDScriptRoot "\Home.ps1")

I apologize if these are very basic questions, I’ve never built a dashboard with multiple pages before.

Product: PowerShell Universal
Version: 1.4.6

I think it has something to do with where the page is redirecting?
I created 2 basic dashboards: Home and File3.

I modified Home.ps1 to what the Pages sample says:

$UDScriptRoot = $PSScriptRoot
$Pages = @()

$Pages += New-UDPage -Name ‘Home’ -Content {
New-UDTypography -Text “$UDScriptRoot\Home.ps1”
. “$UDScriptRoot\Home.ps1”

$Pages += New-UDPage -Name ‘File Three’ -Content {
New-UDTypography -Text “$UDScriptRoot\File3.ps1”
. “$UDScriptRoot\File3.ps1”

New-UDDashboard -Title ‘Home’ -Pages $Pages

And left File3.ps1 as the default dashboard:

New-UDDashboard -Title “File Three” -Content {
New-UDTypography -Text “Hello, World!”
New-UDButton -Text “Learn more about Universal Dashboard” -OnClick {
Invoke-UDRedirect https://docs.ironmansoftware.com

When Viewing Home and clicking on “File Three” I get redirected to http://localhost:5000/Home/File-Three. But if I View File3 directly from VS Code the url is http://localhost:5000/File3/Home

What’s the best way to create pages from multiple ps1 files? I cant do this because I need specific files.

You shouldn’t have to create multiple dashboards for multiple pages.

If you want to use File3.ps1 in your Home dashboard. Just put this in File3.ps1 to see if the output is what you expect. In that case, you can remove the File3 dashboard all together.

New-UDTypography -Text “Hello, World!”
1 Like