PowerShell Universal Dashboard is now more than just dashboards. Today, UD is now capable of Inputs and Dynamic pages to make more versatile dashboards that can update data and show results.
The New-UDInput cmdlet is now available. This cmdlet produces a new card and automatically generates textboxes and checkboxes based on the Param block of the endpoint specified when you define your input component. The following script block defines a function that accepts a string and a bool.
The resulting control looks like this on the dashboard.
When clicking the submit button, the data is sent back to the UD server and passed into the endpoint script block. More input controls are on the way!
Any action you can perform with PowerShell can be taken in the script block. The data can be saved to a database or a REST endpoint could be called. Additionally, you can specify what to do on the client side of the application.
Using the New-UDInputAction cmdlet, you can return an action for the client to take. It currently supports displaying Toast messages and redirecting to local or remote web sites after completing the action.
One great benefit of taking input, is now you can also create dynamic pages based on that input. Dynamic pages define a particular URL pattern. Parts of the URL can be treated as variables and you can tailor your page to match those variables. The portion of the URL that is prefixed with a colon is the replacement section. In the below example, I’m defining a page with a single replacement path component. The Endpoint script block receives that variable when it is called.
The resulting page can then update based on the variable that has been passed to the script block and the URL.
New-UDInputAction also supports redirecting to dynamic pages. Use the RedirectUrl parameter to redirect a user to a new page after an action.
You can pass dynamic pages to New-UDDashboard just like other pages.
Better Error Handling
In the last release of PowerShell Universal Dashboard, Enable-UDLogging and Disable-UDLogging were added to better understand the internals of what UD is doing and to debug issues. In this release, the UI itself is better at dealing with error conditions. Rather than showing a blank screen when things go wrong the UI will attempt to display the error for the component that is failing. For example, if a chart fails to send data due to an issue in a script, that component will now show an error card.
In this example, I spelled Out-UDMonitorData incorrectly and the card indicates the error.
Dashboards will also avoid throwing terminating errors and try to render. If a particular component fails to render within a page or column, the page or column will display the error card. Additionally, the non-terminating error will be presented on the command line.
As always, you can grab the latest version of PowerShell Universal Dashboard on the PowerShell Gallery.