New-UDCard not work

Hello, I am a beginner for PowerShell Universal. I hope to get help.

I deployed PowerShell Universal on IIS. I created a new Dashborad and can´t get this work:

  1. Nothing is showed in Browser except the home label
    New-UDDashboard -Title ‘Hello, World!’ -Content {
    New-UDLayout -Columns 3 -Content {
    New-UDCard
    New-UDCard
    }
    }

  2. I get this eroor: “One or more errors occurred” bei using -EndpointInitialization
    function Test-Function {
    Return 2
    }

$EI = New-UDEndpointInitialization -Function “Test-Function”
$Dashboard = New-UDDashboard -Title “This is a little test” -Content {
New-UDCard -Title “The Title” -Endpoint {Test-Function}
} -EndpointInitialization $EI
$Dashboard

Thank you in advance!
Hong

Hello @Hong answer to question 1. is that you have literally put 2 blank cards on a page, because these cards contain no information nothing will show. You need to look at adding content to the card…please look at Card - PowerShell Universal
As for question 2 I cannot see where you have included the “TEST-Function” in your dashboard, so that endpoint doesnt know what to return in my opinion on that one…Hope this helps

Thank you @psDevUK for your reply.
To Question 1: I added Contents. But still is nothing showed.
New-UDDashboard -Title ‘Hello, World!’ -Content {
New-UDLayout -Columns 3 -Content {
New-UDCard -Title ‘Simple Card 1’ -Content {
“This is some content 1”
}
New-UDCard -Title ‘Simple Card 2’ -Content {
“This is some content 2”
}
New-UDCard -Title ‘Simple Card 3’ -Content {
“This is some content 3”
}
}
}

To question 2
@ I cannot see where you have included the “TEST-Function” in your dashboard

→ I made the lines bold

function Test-Function {
Return 2
}

$ep = New-UDEndpointInitialization -Function “Test-Function”

$Dashboard = New-UDDashboard -Title “This is a little test” -Content {
New-UDCard -Title “The Title” -Endpoint {Test-Function}
} -EndpointInitialization $ep
$Dashboard

The error: “One or more errors occurred” seems to have something to do with
-EndpointInitialization $ep
if I omit -EndpointInitialization $ep, no error appears

Something seems missing on IIS. I tried both on a client without IIS in ths way and both cases work properly. I hope you have tips for me to check.
Case 1
$Dashboard = New-UDDashboard -Title ‘Hello, World!’ -Content {
New-UDLayout -Columns 3 -Content {
New-UDCard -Title ‘Simple Card 1’ -Content {
“This is some content 1”
}
New-UDCard -Title ‘Simple Card 2’ -Content {
“This is some content 2”
}
New-UDCard -Title ‘Simple Card 3’ -Content {
“This is some content 3”
}
}
}
Start-UDDashboard -Dashboard $Dashboard -Port 10000

Case 2:

function Test-Function {
Return 2
}

$ep = New-UDEndpointInitialization -Function “Test-Function”
$Dashboard = New-UDDashboard -Title “This is a little test” -Content {
New-UDCard -Title “The Title” -Endpoint {Test-Function}
} -EndpointInitialization $ep
Start-UDDashboard -Dashboard $Dashboard -Port 10000

I found a way to get case 1 with New-UDCard work. I changed Framework from UniversalDashboard [3.3.3.] to the older version UniversalDashboard [2.9.9]. Now the cards are showed.

But case 2 is still not working.
Our company is ordering Perpetual server.
I really need to use my customized exsting functions inside a Dashboard . It is elementary.
Is Endpoint the right way? I checked, this codes is woking well on my local computer with UniversalDashboard.Community installed. But it isn’t working on IIS. Hope for help.
function Test-Function {
Return 2
}

$ep = New-UDEndpointInitialization -Function “Test-Function”
$Dashboard = New-UDDashboard -Title “This is a little test” -Content {
New-UDCard -Title “The Title” -Endpoint {Test-Function}
} -EndpointInitialization $ep
Start-UDDashboard -Dashboard $Dashboard -Port 10000

I continue trying to get case 2 work on IIS
The following error is found in log:
the term “New-UDEndpointInitialization” is not recognized as the name of a cmdlet, function, script file, or operable program…

I followed this instruction for install UniversalDashbard.community

and then copied the contents from
C:\Program Files\WindowsPowerShell\Modules\UniversalDashboard.Community\2.9.0
into the root folder of website.

Nothing changed. Can anyone help me?

@Hong
New-UDEndpointInitialization no loger available in powershell universal.

Thank you for yur reply.
Is that another way for a dashboard to include a powershell file (e.g. library.ps1) containing all my custom functions? Can you give an example please. I really need help to get on.

You can either dot source the file or use Import-Module to import the functions. You can do so at the top of your dashboard PS1 file.

Import-Module $PSScriptRoot\library.ps1

New-UDDashboard -Title '' -Content {}

It is working ! Thank you very much Adam! :blush:

1 Like