Noob question: Just getting started with Universal Dashboard and I’m getting stuck on converting one of my simple scripts to run in UD. Mainly I’m not sure how to use functions and pass information to the UD elements. I found this forum post that explained this, but I’m unable to get this working. Simplified example of the script:
function New-Password {
return "ExamplePassword"
}
$newPasswordEndInit = New-UDEndpointInitialization -Function "New-Password"
$Dashboard = New-UDDashboard -Title "Generate Password" -Content {
New-UDCard -Title 'Generate Password' -Content {
New-UDButton -Text "Generate Password" -OnClick {
Show-UDToast -Message $getPassword = New-Password
} #-Endpoint {"New-Password"}
New-UDParagraph -Text 'Woud like to output here.'
}
} -EndpointInitialization $newPasswordEndInit
Start-UDDashboard -Dashboard $Dashboard -Port 10001 -AutoReload
If I uncommend the -Endpoint {“New-Password”}, then the whole UDCard fails to load. When I click the button it tells me "Cannot bind argument to parameter ‘Message’ because it is null. I know I’m probably way off on calling that function there. Ultimately I would like to click the button and have a generated password append paragraph below the button and you could click again to generate a second or third one. I didn’t see anything in the documentation to push text into another element kind of like Javascript’s get element by id.