Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Input controls for Universal Dashboard
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Dashboards are the root component for your web page.
Dashboards can contain one or more pages. The simplest dashboard will contain a single page with some content. You can call any PowerShell cmdlet that is available on your machine to populate your dashboard.
Here's an example of simple dashboard that displays some text.
The top-level cmdlet for dashboards is New-UDDashboard
. You need to call it when returning a dashboard. You can use it with or without pages.
The content of the dashboard is a series of components to display on the page. It's a script block that will return all the components in the order they will be rendered on the page. You can use the Grid component to layout items and display things like text with typography.
You can customize the header of the dashboard using several parameters.
To change the navigation layout, use the -Navigation
and -NavigationLayout
parameters.
Components are the individual widgets that you can place on you dashboard. There are components for displaying data, taking user input, adding text and images and more. Components can be downloaded as PowerShell modules and added to your dashboard.
Components are be caused using the standard verb-name syntax for any PowerShell cmdlet.
Learn more about components here.
You can specify multiple pages within a dashboard. Each page defines a route. As for v3, all pages are dynamic. PowerShell will execute on each page load to render the new page. Since UD is a single page application, the web browser does not need to refresh the entire web page when navigating between the different dashboard pages.
Learn more about Pages here.
Built-in variables can be found on the variables page.
You can also use the Debugging Tools with dashboards.
When building a dashboard, you will likely run into issues with cmdlet calls or syntax. Dashboards will auto reload as you make changes to the dashboard files. If a dashboard fails to start, you can navigate to the admin page, click Dashboards and click the Info button next to your dashboard.
The Log tab will show all the logging coming from the PowerShell execution from within in your dashboard. This should allow you to easily see errors and warnings coming from your dashboard.
You can use Write-Debug
to add additional log messages to your dashboard. To enable debug logging, you will have to set the $DebugPreference
variable at the top of your dashboard script.
You can customize the dashboard menu by using the -Menu
parameter.
Dashboards are individual websites created with Universal Dashboard. You can define settings for a dashboard and start and stop the dashboard from within the Universal administrative interface.
Dashboards can be added to Universal using the Add Dashboard button from the Dashboard / Dashboards page.
Name
Name is displayed throughout the UI and returned from the Universal cmdlets.
Base URL
The base URL is the URL that you will access to view this dashboard. This URL needs to be unique within this instance. You can specify the /
root URL if you wish. You will have to visit /admin
to login to the administrative page if you set the dashboard to the root URL.
File Name
The full file name to the dashboard file. This file needs to return a dashboard using New-UDDashboard.
Environment
The environment to run the dashboard within.
Authentication
Enables authentication for the dashboard.
Roles
Defines the role that is required to access the dashboard.
AutoStart
Determines whether the dashboard should start (or restart) when the server starts or changes are made to the dashboard files.
Similar to jobs, dashboards run in separate PowerShell processes. You can start and stop a dashboard process by clicking the Start or Stop button from the Dashboards page.
You can view diagnostic information for a dashboard by clicking the Info button on the Dashboards page. This will show your start information for the dashboard as well as any error that were encountered when starting the dashboard.
You can view the dashboard by clicking the View button. This will take you to the Base URL for the dashboard.
On the dashboard information page, click on the Console tab to view the UD console. The console allows you to run scripts from within the UD runspace so you can better debug the state of your script. You can evaluate variables and run commands that are available to the dashboard. You will be running in the context of your user in regards to the runspace but the process will be running as the service account user.
Persistent runspaces allow you to maintain runspace state within your dashboard endpoints. This is important for users that perform some sort of initialization within their endpoints that they do not want to execute on subsequent calls.
By default, runspaces will be reset after each execution. This will cause variables, modules and functions defined during the execution of an endpoint.
To enable persistent runspaces, you will need to configure an environment for your API. Set the -PersistentRunspace
parameter to enable this feature. This is configured in the environments.ps1
script.
You will need to ensure that the environment is used by the dashboard.
You can automatically grant app tokens to users that visit dashboards. This is useful if you want to invoke the management API for PowerShell Universal from within a dashboard. Your dashboard will need to have authentication enabled and you will have to use the -GrantAppToken
switch parameter on New-PSUDashboard
.
From within your dashboard, you can now invoke the management API without having to worry about app token management. The API will be invoked in the context of the user that is visiting the dashboard.
By default, dashboards will display a toast message when an error is generated within an endpoint script. To avoid this behavior, you can use the -DisableErrorToast
parameter of New-UDDashboard
When starting a dashboard, information about the variables and modules is displayed within the dashboard log. If you wish to suppress this information, you can use the -DisableStartupLogging
parameter.
Built-in variables are listed on the variables page.
A Universal Dashboard website is composed of components. In addition to the core component, you can also extend Universal Dashboard with a large set of community created components.
There are two non-framework components that are built into PSU. These include the Nivo charts library as well as the UDMap component. Additional components can be downloaded from the UD Marketplace.
External components are distributed as PowerShell modules and can be used in a dashboard by using Import-Module
.
When building a dashboard, you can simply call the PowerShell cmdlets within your dashboard script to create a new component.
You can add component modules by clicking the Components button on the Dashboard page and then adding the components. This list will also include components downloaded from the Marketplace.
Each version of PowerShell Universal includes some built in components. These components are included in the local installation directory. During start up, they are deployed to the assets folder. By default, this folder is %ProgramData%\PowerShellUniversal\Dashboard\Components
.
You can change the assets folder by updating appsettings.json.
You can manually install components into the assets folder by including the appropriate folder structure and files. All components need to be valid PowerShell modules.
Each component should be in a folder with the module name and an additional folder with the version.
You can also include components within the code Repository. By including them in the repository, they will be downloaded when using git sync. This functionality is only enabled when git sync is enabled.
After a git pull is performed on the remote repository, Components will be automatically loaded and available within the Components page within PowerShell Universal. The structure and layout of the components folder is the same as the main assets folder.
Examples of things you can do with dashboards.
Dynamic regions allow you control the reload of data within the region.
New-UDDynamic
allows you to define a dynamic region. Pages themselves are dynamic in nature. This means that every time a page is loaded, it runs the PowerShell for that page. Sometimes, you may want to reload a section of a page rather than the whole page itself. This is when you will want to use dynamic regions.
This dynamic region reloads when the button is clicked.
An array of arguments may be passed to the dynamic region.
Note that the arguments are static and do not change when Sync-UDElement is invoked.
Dynamic regions enable the ability to auto refresh components after a certain amount of time. The entire region's script block will be run when autorefreshing.
If you have multiple related components that use the same data, consider putting them in the same dynamic region to improve performance.
Sometimes refreshing a dynamic component may take some time. For example, if you are querying another service's REST API or a data. Dynamic regions support configuration of the component that shows when the region is reloading. By default, nothing is shown. This can be any Universal Dashboard component.
Error boundary component for Universal Dashboard.
The New-UDErrorBoundary
component is used for isolating portions of a dashboard to contain components that may throw an error. Many Universal Dashboard components use the error boundary component internally.
If you'd like to isolate a portion of your dashboard to prevent the entire page from failing to load, you can use the following syntax.
If any error is thrown from the content, you will see an error such as thing.
Information about Universal Dashboard pages.
A dashboard can consist of one or more pages. A page can have a particular name and URL. You can define a URL that accepts one or more variables in the URL to define a dynamic page.
Within the dashboard editor, expand the Pages navigation menu and click New Page.
You can edit a page by clicking the link in the menu. The code editor will switch to the page's content.
To reference the page in your dashboard, use Get-UDPage
.
A basic page can be defined using the New-UDPage
cmdlet. You could navigate to this page by visiting the /dashboard
URL of your dashboard.
Dashboards can have multiple pages and those pages can be defined by passing an array of UDPages to New-UDDashboard
You may want to organize your dashboard into multiple PS1 files. You can do this using pages.
A page can have a custom URL by using the -Url
parameter. You could navigate to this page by visiting the /db
URL of your dashboard.
You can define a page with variables in the URL to create pages that adapt based on that URL.
Query string parameters are passed to pages and other endpoints as variables.
For example, if you visited a page with the following query string parameter: http://localhost:5000/dashboard/Page1?test=123
You would then have access to a $Test
variable that contained the value 123
.
The following options are available for customizing the header.
Use the -HeaderPosition
parameter to adjust the behavior of the header.
absolute\fixed - Remains at the top of the page, even when scrolling
relative - Remains at the top of the page. Not visible when scrolling.
You can adjust the colors of the header by specifying the -HeaderColor
and -HeaderBackgroundColor
parameters. These colors will override the theme colors.
Custom navigation can be defined with a list. List items can include children to create drop down sections in the navigation.
Dynamic navigation can be used to execute scripts during page load to determine which navigation components to show based on variables like the user, IP address or roles.
You can generate dynamic navigation by using the -LoadNavigation
parameter. The value of the parameter should be a script block to execute when loading the navigation.
The permanent layout creates a static navigation drawer on the left hand side of the page. It cannot be hidden by the user.
The temporary layout creates a navigation drawer that can be opened using a hamburger menu found in the top left corner. This is the default setting.
You can use New-UDAppBar
with a blank page to create horizontal navigation.
You can display a logo in the navigation bar by using the -Logo
parameter.
Now, when creating your page, you can specify the path to the logo.
The logo will display in the top left corner.
You can define custom content to include in the header by using the -HeaderContent
parameter.
Page titles are static by default, but you can override this behavior by using -LoadTitle
. It will be called when the page is loaded. This is useful when defining pages in multilingual dashboards.
Static pages allow for better performance by not executing PowerShell to load the content of the page. This can be useful when displaying data that does not require dynamic PowerShell execution. The page content is constructed when the dashboard is started.
Static pages do not have access to user specific data. This includes variables such as:
$Headers
$User
$Roles
You can still include dynamic regions within pages. These dynamic regions will have access to user data. Reloading the below example will update the date and time listed in the page.
This document outlines how to build custom Universal Dashboard components.
Universal Dashboard is extensible and you can build custom JavaScript components and frameworks. This document will cover how to build custom components that integrate with the Universal Dashboard platform.
This is an advanced topic and not required if you simply want to use Universal Dashboard. There are a lot of existing custom components available on the .
Look at on how to get started with custom components for full end-to-end example.
Below is a list of some of the technologies used when building Universal Dashboard components. You will not need to be an expert to produce a component but should be aware of what to search when you encounter a problem.
Universal Dashboard's client-side application is built using the . React makes it easy to build components that update the DOM only when necessary and has a pretty robust ecosystem of users. It's one of the most popular JavaScript frameworks at the time of this writing.
is a transcompiler for JavaScript. It works well with React and allows you to use modern constructs while compiling for backwards compatibility of browsers. Universal Dashboard uses Babel for it's core component frameworks.
is an asset bundler. It's extremely customizable and is responsible for turning your JSX files into a bundle that can then be distributed with Universal Dashboard components.
There are some basic parts to a Universal Dashboard component. You will need to understand the structure in order to successfully build your own.
Universal Dashboard custom components are PowerShell modules. They export functions that can be used to create the component when run within a dashboard. The PowerShell module is also responsible for registering the JavaScript assets with Universal Dashboard.
The JavaScript bundle is produced by the Webpack bundling process. It consists of one or more JS files that you will need to register with UD.
The most basic structure for a UD component module will include a single JavaScript file, a PSM1 file to export a function and register the JavaScript and a PSD1 module manifest.
This following section will take you step-by-step through the different aspects of building a UD component. This assumes you are running PowerShell Universal 1.2 or later and using the PowerShell Universal Dashboard v3 framework.
You will need to install the following dependencies before creating your component.
After installing Node, you will have access to the npm
command. You will need to initialize the node package to start. This will create a package.json
file in your directory.
You will need several JavaScript packages to build your bundle. You will first want to install the dev dependencies. These are used to build your project.
Next, you'll want to install the universal-dashboard
package along with any other packages you wish to use in your component. We are using React95 in this example. We will build a control based on that library.
You will need to create a .babelrc
file to configure Babel for React.
Webpack is extremely customizable and sometimes very hard to get right. Below is a basic webpack.config.js
file you can use to configure Webpack. You can safely change the ud95
entry key name and library value to one that matches your library.
Now you can build your first component. You will need to export a single function component from your component.jsx file. We suggest the use of functional React components rather than class-based React components. We need to wrap the component in withComponentFeatures to ensure the component has access to the Universal Dashboard platform features.
Once your component is completed, you'll need to add it to an index
.js file. The entry point for your library is the first place Webpack will look. It will discover all other components from import statements in your code. The index.js file is where you should register your components. You can use the registerComponent
function to do so.
To bundle the JavaScript, run the following command to start webpack. This will output a file into the dist folder.
Now you will need to create a PowerShell script that registers and creates your component.
First, register the JavaScript with Universal Dashboard.
Next, create a function that returns a hashtable that defines which component we are creating and which props to set.
The type
property of your hashtable needs to match with the first parameter of registerComponent
that you called in your JavaScript.
We suggest the use of InvokeBuild to create a build script to run all the steps of packaging and staging your module. The below build script deletes the dist folder, runs an NPM install to install packages, runs an NPM build to bundle the JavaScript and then copies the PS module to the dist folder.
Props are values that are either passed from the PowerShell hashtable provided by the user or by the Universal Dashboard withComponentsFeature
high-order function.
The properties that you set in your hashtable in PowerShell will automatically be sent in as props to React component.
For example, if you set the text
property of the hashtable like this.
Then you will have access to that prop in React.
Endpoints are special in the way they are registered and the way that they are passed as props to your component. You will need to call Register
on the endpoint in PowerShell and pass in the Id and PSCmdlet variables.
Endpoints are created from ScriptBlocks and are executed when that event happens.
Universal Dashboard will automatically wire up the endpoint to a function within JavaScript. This means that you can use the props to call that endpoint.
Notice the props.onClick
function call. This will automatically call the PowerShell script block on the server.
The setState
prop is used to set the state of the component. This ensures that the state is tracked and your component will work with Get-UDElement
.
For example, with a text field, you'll want to call props.setState
and pass in the new text value for the state.
The children
prop is a standard React prop. If your component supports child items, such as a list or select box, you should use the standard props.children
prop to ensure that the cmdlets Add-UDElement
, Remove-UDElement
and Clear-UDElement
function correctly.
To publish to the Marketplace, you simply need to publish to the PowerShell Gallery but include the ud-component
tag in your module manifest. The marketplace syncs with the Gallery every hour and your component will be enabled for anyone to find after that.
Information about UDElements.
The New-UDElement
cmdlet allows you to create custom React elements within your dashboard. Similar to New-UDHtml
, you can define HTML elements using New-UDElement
. Unlike, New-UDHtml
, you can update elements, set auto refresh and take advantage of the React component system.
You need to specify the -Tag
and -Content
when creating an element. The below example creates a div tag.
You can nest components within each other to create HTML structures. For example, you could create an unordered list with the following example.
You can select attributes of an element (like HTML attributes) by using the -Attributes
parameter. This parameter accepts a hashtable of attribute name and values. The below example creates red text.
You can wrap any component with New-UDElement and add an event handler.
You can define the -AutoRefresh
, -RefreshInterval
and -Endpoint
parameters to create an element the refreshes on a certain interval. The below example creates an element that refreshes every second and displays the current time.
You can use the Set-UDElement
cmdlet to set element properties and content dynamically. The following example sets the content of the element to the current time.
You can also set attributes by using the -Properties
parameter of Set-UDElement
. The following example sets the current time and changes the color to red.
You can add child elements using Add-UDElement
. The following example adds child list items to an unordered list.
You can clear the child elements of an element by using Clear-UDElement
. The following example clears all the list items from an unordered list.
You can force an element to reload using Sync-UDElement
. The following example causes the div to reload with the current date.
You can remove an element by using Remove-UDElement
.
The below example creates a New-UDPeoplePicker
component from existing UD components. You can use the New-UDPeoplePicker
component in your dashboards. This function can either be defined within your dashboard directly or within a .
This feature requires a .
You can prevent users from accessing pages based on their role by using the -Role
parameter of pages. You can configure roles and role policies on the .
You can customize the navigation of a page using the -Navigation
and -NavigationLayout
parameters. Navigation is defined using the component. Navigation layouts are either permanent or temporary.
First, setup a to host your logo.
To customize the style of your logo, you can use a and target the ud-logo
element ID.
For a full example of a component, .
package.json
that you can also use as a starting point.
The is an aggregator of the PowerShell Gallery that lists Universal Dashboard components. The UD Marketplace automatically hooks into PowerShell Universal v1.3 or later where you can easily install additional components.
****
****
Date and time component for Universal Dashboard.
The New-UDDateTime
component is used for formatting dates and times within the client's browser. By using the client's browser, you can format the time based on the local time zone and locale settings for the user.
The date and time component uses DayJS. For a full list of custom formatting options, visit the DayJS documentation.
By default, the date and time will be formatted using the LLL
localized formatting template.
Resulting output: August 16, 2018 8:02 PM
You can specify custom formatting strings using the DayJS formatting template.
Resulting output: 25/01/2019
You can specify the locale to display the date and time in.
Resulting output: 13 de septiembre de 2022 7:30
Chip component for Universal Dashboard.
Chips are compact elements that represent an input, attribute, or action.
Chips allow users to enter information, make selections, filter content, or trigger actions.
While included here as a standalone component, the most common use will be in some form of input, so some of the behavior demonstrated here is not shown in context.
Shows a toast when the chip is clicked.
Examples of badges containing text, using primary and secondary colors. The badge is applied to its children.
Alert component for Universal Dashboard.
Alerts provide a simple way to communicate information to a user.
Alerts have four different severities and can include text or other content.
Alerts can contain any component and also a title.
Icon component for Universal Dashboard
FontAwesome icons to include in your dashboard. Icon names are slightly different than those shown on the FontAwesome website. For example, if you want to use the network-wired
icon, you would use the following string.
We include FontAwesome v6 with PowerShell Universal. You can use Find-UDIcon
to search through the list of included icons.
The UniversalDashboard.FontAwesomeIcons
enum should not be used and is only included for backwards compatibility. Many of the icons are no longer a part of FontAwesome 6.
Create icons by specifying their names. You can use the icon reference below to find icons.
Set the size of the icon. Valid values are: xs
, sm
, lg
, 2x
, 3x
, 4x
, 5x
, 6x
, 7x
, 8x
, 9x
, 10x
Rotate icons. The value represents the degrees of rotation.
Add a border to your icon.
Apply CSS styles to your icon.
You can use custom icon sets available on the PowerShell Universal Modules page. First, install the module and then use the icon with other components.
Within your dashboard, call the icon cmdlet.
Data grid component for Universal Dashboard.
The UDDataGrid
component is an advanced version of the table that is useful for displaying large amounts of data. It supports many of the same features as the table but also provides complex filtering, row virtualization, multi-column sort and more.
Data grids load their data via the -LoadRows
event handler. You will need to return a hashtable that contains the row data and the total number of rows.
Columns are defined using hashtables.
Prior to version 3.3., column field names must be in camel case. For example, the property Name
would need to be name
while the property FirstName
would need to be firstName
.
Columns are customizable using hashtables. You can find the supported properties below.
You can render custom components in columns by specifying render
within the column hashtable. You can access the current row's data by using the $EventData
or $Row
variable
In this example, the number is shown in the name column with a New-UDTypography
component.
Column fluidity or responsiveness can be achieved by setting the flex
property of a column.
The flex
property accepts a value between 0 and ∞. It works by dividing the remaining space in the grid among all flex columns in proportion to their flex
value.
For example, consider a grid with a total width of 500px that has three columns: the first with width: 200
; the second with flex: 1
; and the third with flex: 0.5
. The first column will be 200px wide, leaving 300px remaining. The column with flex: 1
is twice the size of flex: 0.5
, which means that final sizes will be: 200px, 200px, 100px.
To set a minimum and maximum width for a flex
column set the minWidth
and the maxWidth
property on the column.
The -LoadRows
parameter is used to return data for the data grid. Table state will be provided to the event handler as $EventData
. You will find the following properties within the $EventData
object.
To implement paging, you can access the page
and pageSize
properties of the $EventData
variable.
The filter hashtable is included in the $EventData
for the -LoadRows
event handler when a filter is defined. The hashtable has a structure as follows.
The items property contains an array of columns, operators and values. You can use these to filter your data.
The link operator field is used to specify the link between the filters. This can be and
or or
.
The $EventData
object will contain a Sort
property when the user sorts the data grid. It contains properties for each column that is sorted. The properties will start as 0 and increment as more columns are sorted.
For example, you can access the first sorted column as follows.
You will also receive the sort direction for each column.
You can use the -LoadDetailedContent
event handler to display additional information about the row you are expanding. Information about the current row is available in $EventData.row
.
Tables provide editor support by specifying the -OnEdit
event handler. The new row data will be provided as $EventData
. You can chose to return updated row information (for example, adjusting something the user has entered) and return it from the event handler. If you do not return anything, the row will reflect what the user entered.
The $EventData
has the following format.
Ensure that you provide the editable
property to each column you wish for the user to edit.
To override the default export functionality, use the -OnExport
event handler. $EventData
will be an array of rows with their values. You should use Out-UDDataGridExport
to return the data from -OnExport
.
In this example, we generate an array of 10,000 records. We will create a new function, Out-UDDataGridData
to manage the paging, sorting and filtering.
In this example, we'll query the PowerShell Universal database with dbatools.
List component for Universal Dashboard.
Lists are continuous, vertical indexes of text or images.
Lists are a continuous group of text or images. They are composed of items containing primary and supplemental actions, which are represented by icons and text.
You can define an action to take when an item is clicked by using the -OnClick
parameter of New-UDListItem
.
Table component for Universal Dashboard
Tables display sets of data. They can be fully customized.
Tables display information in a way that’s easy to scan, so that users can look for patterns and insights. They can be embedded in primary content, such as cards.
A simple example with no frills. Table columns are defined from the data.
Define custom columns for your table.
Define column rendering. Sorting and exporting still work for the table.
Column width can be defined using the -Width
parameter. You can also decide to truncate columns that extend past that width.
You can configure custom filters per column. The table supports text
, select
, fuzzy
, slider
, range
, date
, number
, and autocomplete
filters.
To enable search, use the -ShowSearch
parameter on New-UDTable
.
When using custom columns, you will need to add the -IncludeInSearch
parameter to the columns you'd like to include in the search.
Process data on the server so you can perform paging, filtering, sorting and searching in systems like SQL. To implement a server-side table, you will use the -LoadData
parameter. This parameter accepts a ScriptBlock
. The $EventData
variable includes information about the state of the table. You can use cmdlets to process the data based on this information.
The $EventData
object contains the following properties.
You may want to allow the user to take action on the current set of displayed data. To do so, use Get-UDElement
in the input object you want to retrieve the data from and get the table by Id. Once you have the element, you can use the CurrentData
property of the element to get an array of currently displayed rows.
By default, paging is disable and tables will grow based on how many rows of data you provide. You can enable paging by using the -ShowPagination
cmdlet (alias -Paging
). You can configure the page size using the -PageSize
cmdlet.
By default, the page size selector provides an option to show all rows. If you want to prevent users from doing this, use the -DisablePageSizeAll
cmdlet.
You can change the location of the pagination control by using the -PaginationLocation
parameter. It accepts top, bottom and both.
To enable sorting for a table, use the -ShowSort
parameter. When you enable sorting, you will be able to click the table headers to sort the table by clicking the headers. By default, multi-sort is enabled. To multi-hold shift and click a column header.
You can control which columns can be sorted by using New-UDTableColumn
and -ShowSort
parameter.
By default, the sorting of a table has 3 states. Unsorted, ascending and descending. If you would like to disable the unsorted state, use the -DisableSortRemove
parameter of New-UDTable
.
Tables support selection of rows. You can create an event handler for the OnRowSelected
parameter to receive when a new row is selected or unselected or you can use Get-UDElement
to retrieve the current set of selected rows.
The following example creates a table with row selection enabled. A toast is show when clicking the row or when clicking the GET Rows button.
The $EventData
variable for the -OnRowSelected
event will include all the columns as properties and a selected property as to whether the row was selected or unselected.
For example, the service table data would look like this.
You can include additional information within the table by using the -OnRowExpand
parameter of New-UDTable
. It accepts a ScriptBlock that you can use to return additional components.
Tables support exporting the data within the table. You can export as CSV, XLSX, JSON or PDF. You can define which columns to include in an export and choose to export just the current page or all the data within the table.
Hidden columns allow you to include data that is not displayed in the table but is included in the exported data.
The following hides the StartType column from the user but includes it in the export.
You can control the export functionality with a PowerShell script block. This is useful when exporting from server-side sources like SQL server tables.
In this example, I have a SQL table that contains podcasts. When exporting, you will receive information about the current state of the table to allow you to customize what data is exported.
You can decide which export options to present to your users using the -ExportOption
cmdlet. The following example would only show the CSV export option.
You can use the -TextOption
parameter along with the New-UDTableTextOption
cmdlet to set text fields within the table.
You can externally refresh a table by putting the table within a dynamic region and using Sync-UDElement
.
This example creates a button to refresh the table.
If you use the -LoadData
parameter, you can sync the table directly. This has the benefit of maintaining the table state, such as the page and filtering, after the refresh.
You can use the -ShowRefresh
parameter to provide a refresh button for server-side tables.
You can use a theme to create a table with alternating row colors.
Tree view component for Universal Dashboard.
New-UDTreeView
allows you to create a tree of items and, optionally, dynamically expand the list when clicked.
Create a basic tree view by using the New-UDTreeNode
cmdlet.
Dynamic tree views allow you to run PowerShell whenever a node is clicked. You can then return a list of nodes that should be rendered underneath the clicked node. You can also take other actions such as opening a modal or showing a toast.
Tooltip component for PowerShell Universal.
Tooltips display informative text when users hover over an element.
Place the tooltip on top
, bottom
, left
or right
.
Tooltip content can contain any UD element.
Tooltips can be over various types including: "dark", "success", "warning", "error", "info", "light"
Property | Description | Type\Value |
---|---|---|
Property | Description | Type |
---|---|---|
Property | Description | Type |
---|---|---|
Property | Description | Type |
---|---|---|
Property Name | Type | Description |
---|
Align
How to align the data within the column.
Left, Center, Right
CellClassName
A CSS class to apply to cells in this column
string
ColSpan
The number of columns this column should span.
Integer
Description
A tooltip description of the column
string
DisableColumnMenu
Disable the column menu for this column
boolean
DisableExport
Disable exporting of the data in this column
boolean
Editable
Whether or not this column can be edited
boolean
Field
The field (property) to use when displaying the value in the column.
String
Filterable
Whether this column can be used in filters.
boolean
Flex
The flex
property accepts a value between 0 and ∞. It works by dividing the remaining space in the grid among all flex columns in proportion to their flex
value.
float
HeaderAlign
How to align header text.
left, center, right
HeaderName
The title to display in the header.
String
Hide
Whether to hide the column
boolean
Hideable
Whether a column can be hidden by the user.
boolean
HideSortIcon
Whether to hide the sort icon for the column
boolean
MaxWidth
The maximum width of the column
integer
MinWidth
The minimum width of the column
integer
Pinnable
Whether the column can be pinned.
boolean
Render
A script block to render components in the column
ScriptBlock
Resizable
Whether the column can be resized
boolean
Sortable
Whether the column can be sorted.
boolean
Type
The type of data within the column
string, number, date, dateTime, boolean, actions
Width
How wide the column should be in pixels.
Integer
Filter
A filter object that you can use to construct filters against your data.
Hashtable
Page
The current page. Starts at 0.
Integer
PageSize
The number of records in a page.
Integer
Sort
The sort options for the table
Hashtable
ColumnField
The name of the field to filter
String
OperatorValue
The type of operator to use when filtering the data.
String
Value
The value used to filter
Object
Field
The field to sort.
String
Sort
The direction to sort the field.
asc, desc
Filters | Hashtable[] @{ id = 'fieldName' value = 'filterValue' } | A list of filter values. Each hashtable has an |
OrderBy | Hashtable @{ field = "fieldName" } | Property name to sort by. |
OrderDirection | string |
|
Page | int | The current page (starting with 0). |
PageSize | int | The selected page size. |
Properties | string[] | An array of properties being shown in the table. |
Search | string | A search string provided by the user. |
TotalCount | int | The total number of records before filtering or paging. |
Image component for dashboards.
Display an image based on a URL. You can host URLs using Published Folders.
Display an image based on a file local to the server.
Change the size of the image using the -Width
and -Height
parameters.
Apply additional attributes to the image.
Typography component for Universal Dashboard
Use typography to present your design and content as clearly and efficiently as possible.
Too many type sizes and styles at once can spoil any layout. A typographic scale has a limited set of type sizes that work well together along with the layout grid.
You can use the -Style
parameter to define colors for your text.
You can use theme-based styling by using the -Sx
parameter of New-UDTypography
. For example, to apply the secondary text color, you can use the following syntax.
Charting components for Universal Dashboard.
Universal Dashboard provides several built-in charting solutions to help visualize your data retrieved from PowerShell.
Universal Dashboard integrates with ChartJS.
To create a chart, use New-UDChartJS
and New-UDChartJSData
. The below chart shows the top ten CPU using processes.
A bubble chart consists of x and y coordinates and an r value for the radius of the circles.
Colors can be defined using the various color parameters of New-UDChartJS
.
By default, you do not need to define data sets manually. A single data set is created automatically when you use the -DataProperty
and -LabelProperty
parameters. If you want to define multiple data sets for a single chart, you can use the -Dataset
property in conjunction with New-UDChartJSDataset
.
You can take action when a user clicks the chart. This example shows a toast with the contents of the $Body
variable. The $Body
variable contains a JSON string with information about the elements that were clicked.
You can use New-UDDynamic
to create charts that refresh on an interval.
Monitors are a special kind of chart that tracks data over time. Monitors are good for displaying data such as server performance stats that change frequently. You return a single value from a monitor and it is graphed automatically over time.
The New-UDChartJS
cmdlet supports accepting advanced ChartJS options. You can use the -Options
parameter to pass in a hashtable.
This example hides the legend.
You can include a title with the title option.
Universal Dashboard integrates with Nivo Charts. Below you will find examples and documentation for using these charts.
All the Nivo charts can be created with New-UDNivoChart
. You will specify a switch parameter for the different types of charts. Each chart type will take a well defined data format via the -Data
parameter.
Nivo provides the ability to specify patterns to display over data sets. You can configure these patterns with New-UDNivoPattern
and New-UDNivoFill
.
Nivo charts provide responsive widths so they will resize automatically when placed on a page or the browser is resized. A height is required when using responsive widths.
Like many components in Universal Dashboard v3, Nivo charts do not define auto-refresh properties themselves. Instead, you can take advantage of New-UDDynamic
to refresh the chart on an interval.
Nivo charts support OnClick event handlers. You will be provided with information about the data set that was clicked as JSON.
Map component for Universal Dashboard.
The UDMap component is a robust control that provides a huge set of features. You can select base layers, configure togglable layers, set markers, define vectors and interact with other Universal Dashboard components.
This basic map defines a simple base layer using the wmflabs.org tile server. You can use your own custom tile server by specifying a URL. The map is position over Hailey, Idaho.
You can enable the layer control by using the New-UDMapLayerControl
cmdlet. This map defines several layers with components that you can toggle on and off. You can only have one base layer selected as a time. Map overlay layers can toggle on and off.
Markers are used to highlight particular locations.
You can specify custom icons for markers using the -Icon
parameter.
You can create a popup when clicking the marker by using the -Popup
parameter and the New-UDMapPopup
cmdlet.
Heatmaps can be defined by creating a heatmap layer. The intesity and location of the heatmap clusters can be defined by using the New-UDMapHeatmapLayer
cmdlet.
Marker clusters group together markers that are close to each other. As you zoom in or out, the clusters will either combine or explode.
Maps provide a series of interactive capabilities for add components to and manipulating the map.
Backdrop component for Universal Dashboard.
The backdrop component places an overlay over the drop of the entire page. It's useful for displaying loading states.
To create a basic backdrop, you can use the New-UDBackdrop
cmdlet and include content to show within the backdrop. The content will be centered on the page. To show the backdrop, use the -Open
switch parameter.
The backdrop provides an -OnClick
handler that you can use to close the backdrop when clicked. You can use Set-UDElement
to open and close the backdrop.
Modal component for Universal Dashboard.
Modals inform users about a task and can contain critical information, require decisions, or involve multiple tasks.
Full width modals take up the full width as defined by the -MaxWidth
parameter.
Persistent modals do not close when you click off of them. You will have to close it with Hide-UDModal
.
You can use the Hide-UDModal
button to hide a modal that is currently show.
You can style modules using the -Style
, -HeaderStyle
, -ContentStyle
and -FooterStyle
parameters. Style is applied to the entire modal itself and the individual section styles are only applied to those sections. The value for these parameters are hashtables of CSS values.
A skeleton component for PowerShell Universal Dashboard.
A skeleton is a form of a loading component that can show a placeholder while data is received.
There are three variants that you can use for a skeleton. You can use a circle, text or a rectangle. You can also define the height and width of the skeleton.
Skeletons will use the pulsate animation by default. You can also disable animation or use a wave animation.
Progress component for Universal Dashboard
Check component for Universal Dashboard
Checkboxes allow the user to select one or more items from a set.
Checkboxes can be disabled and checked by default
Create checkboxes that use any icon and style.
Create checkboxes that fire script blocks when changed.
You can adjust where the label for the checkbox is placed.
You can use Get-UDElement
to get the value of the checkbox. Get-UDElement
will also return other properties of the checkbox component.
The following example shows a toast message with the value of the checkbox.
Code editor component for Universal Dashboard.
The code editor component allows you to host the editor within your dashboards.
You can create a new code editor with the New-UDCodeEditor
cmdlet. Specifying the -Language
parameter will enable syntax highlighting for that language. You will need to specify a height in pixels.
Use the -Code
parameter to specify code that will be populated within the code editor when it loads.
You can retrieve code from another component using the Get-UDElement
cmdlet and accessing the code property of the hashtable that is returned.
You can set code from another component using the Set-UDElement
cmdlet. Specify the code value in a hashtable passed to the -Properties
parameter.
The documentation is for an upcoming feature of PowerShell Universal .
The Monaco editor supports a wide range of options. If you wish to use options that aren't available on the New-UDCodeEditor
cmdlet, you can use the -Options
parameter and pass a hashtable of options instead.
Floating action button component for Universal Dashboard
A floating action button (FAB) performs the primary, or most common, action on a screen.
A floating action button appears in front of all screen content, typically as a circular shape with an icon in its center. FABs come in two types: regular, and extended.
Only use a FAB if it is the most suitable way to present a screen’s primary action.
Only one floating action button is recommended per screen to represent the most common action.
Form component for Universal Dashboard
Forms provide a way to collect data from users.
Forms can include any type of control you want. This allows you to customize the look and feel and use any input controls.
Data entered via the input controls will be sent back to the the OnSubmit
script block when the form is submitted. Within the OnSubmit
event handler, you will access to the $EventData
variable that will contain properties for each of the fields in the form.
For example, if you have two fields, you will have two properties on $EventData
.
The following input controls automatically integrate with a form. The values that are set within these controls will be sent during validation and in the OnSubmit
event handler.
Simple forms can use inputs like text boxes and checkboxes.
Since forms can use any component, you can use standard formatting components within the form.
When a form is submitted, you can optionally return another component to replace the form on the page. You can return any Universal Dashboard component. All you need to do is ensure that the component is written to the pipeline within the OnSubmit
event handler.
Form validation can be accomplished by using the OnValidate script block parameter.
You can define an -OnCancel
event handler to invoke when the cancel button is pressed. This can be used to take actions like close a modal.
Although you can return components directly from a form, you may want to retain the form so users can input data again. To do so, you can use Set-UDElement
and a placeholder element that you can set the content to.
In this example, we have an empty form that, when submitted, will update the results
element with a UDCard.
You define fields that accept string, number, integer, enum and boolean types. This changes the type of input shown.
You can use the required
property to set a list of required properties.
Note that the properties need to be lower case! For example, you need to ensure the keys in your properties hashtable are lower case and the list of required properties are also lower case.
You can use the schemaUI
property to modify the ordering of the fields.
You can create forms that accept 0 to many objects. The user will be able to add and remove objects to the form.
You can automatically generate forms based on scripts in your PowerShell Universal environment. Script forms will generate input components based on the param
block. Script forms automatically support progress and feedback.
Script forms also support displaying the output as text or a table.
Date Picker component for Universal Dashboard
Date pickers pickers provide a simple way to select a single value from a pre-determined set.
Date pickers can be used in and .
The OnChange event handler is called when the date changes. You can access the current date by using the $Body
variable.
You can customize how the date picker is shown. The default is the inline
variant that displays the date picker popup inline with the input control. You can also use the dialog
variant that pops the date picker up in the middle of the screen. Finally, the static
variant displays the date picker without having to click anything.
To set the locate of the date picker, specify the -Locale
parameter.
By default, the user can select any date. To specify minimum and maximum dates, using the -Minimum
and -Maximum
parameters.
A text editor component for Universal Dashboard.
The editor component is based on . It's a block editor that accepts text, links, lists, code and images.
When working with the editor, you can receive data about the current document via the OnChange
parameter. By default, data is returned in the Editor.js .
To create a basic editor, use the New-UDEditor
cmdlet.
The editor will be available and you can add new blocks by clicking the plus button.
You can also use the HTML render plugin by specifying the -Format
parameter.
To specify the default data for the editor, use the -Data
parameter. You need to specify the JSON block format.
Button component for Universal Dashboard
Buttons allow users to take actions, and make choices, with a single tap.
Contained buttons are high-emphasis, distinguished by their use of elevation and fill. They contain actions that are primary to your app.
Outlined buttons are medium-emphasis buttons. They contain actions that are important, but aren’t the primary action in an app.
You can control the pixel size of a button based on pixel size by using the Style parameter
Sometimes you might want to have icons for certain button to enhance the UX of the application as we recognize logos more easily than plain text. For example, if you have a delete button you can label it with a dustbin icon.
You can specify a script block to execute when the button is clicked
Loading buttons will display a loading icon while an event handler is running. This is useful for longer running events.
Autocomplete component for Universal Dashboard
The autocomplete is a normal text input enhanced by a panel of suggested options.
Creates a basic autocomplete with a static list of options
When text is typed, it can be filtered with OnLoadOptions
. $Body
will contain the current text that is typed.
This example filters the array with Where-Object
.
$Body
contains the currently selected item. The OnChange event will fire when the user selects one or more items.
You can place an icon before an autocomplete by using the -Icon
parameter.
OnEnter is triggered when the user presses the enter key within the autocomplete.
You can use New-UDAutoCompleteOption
to specify name and values.
For a full list of options, check the interface.
Instead of defining all the layout and logic for forms using cmdlets, you can also define a form based on a hashtable of schema. This version of forms is based on .
If you define a script block for the -OnChange
event handler. The $EventData
variable will contain the current status of the editor. By default, this returns the Editor.JS .
In order to support images, you will need to provide a in which to upload the images. Once a published folder is defined, images can be uploaded directly in the editor. They will be placed within the directory and then served through the request path.
Name | Type | Description | Required |
---|
Id | string | The ID of this component. |
Data | Hashtable | The Editor.JS data for this component |
OnChange | ScriptBlock | The script block event handler to call when the editor data changes. |
Format | string | Whether to return either json or html in the OnChange script block. |
Link component for Universal Dashboard.
Create a hyper link in a dashboard.
Create a basic link that goes to a web page.
Adjust the underline and text style.
Open the link a new window when clicked.
Execute a PowerShell script block when the link is clicked.
Radio component for Universal Dashboard
Radio buttons allow the user to select one option from a set.
Use radio buttons when the user needs to see all available options. If available options can be collapsed, consider using a dropdown menu because it uses less space.
Radio buttons should have the most commonly used option selected by default.
An event handler that is called when the radio group is changed. the $Body variable will contain the current value.
Set the default value of the radio group.
You can use custom formatting within the radio group. The below example will place the radio buttons next to each other instead of on top of each other.
Switch component for Universal Dashboard
Switches toggle the state of a single setting on or off.
Switches are the preferred way to adjust settings on mobile. The option that the switch controls, as well as the state it’s in, should be made clear from the corresponding inline label.
Create a basic switch.
Respond to when a switch value is changed. The $EventData
variable will include whether or not the switch was checked or unchecked.
You can retrieve the value of the switch within another component by using Get-UDElement
. Use the Checked property to determine whether the switch is checked out not.
Slider component for Universal Dashboard.
Sliders allow users to make selections from a range of values.
Sliders reflect a range of values along a bar, from which users may select a single value. They are ideal for adjusting settings such as volume, brightness, or applying image filters.
Textbox component for Universal Dashboard
A textbox lets users enter and edit text.
A password textbox will mask the input.
You can create a multiline textbox by using the -Multiline
parameter. Pressing enter will add a new line. You can define the number of rows and the max number of rows using -Rows
and -RowsMax
.
You can use Get-UDElement
to get the value of a textbox
You can set the icon of a textbox by using the -Icon
parameter and the New-UDIcon
cmdlet.
The textbox mask is accomplished using react-imask. You can specify RegEx and pattern matching.
This example creates a mask for US based phone numbers.
The default behavior of -Mask
is to return the masked value in forms and Get-UDElement
. You can return the unmasked value by specifying the -Unmask
parameter.
The -OnEnter
event handler is executed when the user presses enter in the text field. It is useful for performing other actions, like clicking a button, on enter.
The -OnBlur
event handler is executed when the textbox loses focus.
Use the -OnValidate
event handler to validate input typed in the textbox.
Select component for Universal Dashboard
Select components are used for collecting user provided information from a list of options.
Create a simple select with multiple options.
Create a select with groups of selections.
Execute a PowerShell event handler when the value of the select is changed. $EventData[0] for the single item that was selected.
Execute a PowerShell event handler when the more than one value of the select is changed. $EventData is an array of the selected items.
Retrieve the value of the select from another component.
Drawer component for Universal Dashboard
A permanent drawer will be shown at all times. By default, it is show on the left side of the screen.
A transfer list (or "shuttle") enables the user to move one or more list items between lists.
Create a simple transfer list.
Use the OnChange
event handler to get the value of the selected items.
Transfer lists can be used within forms and steppers.
Component for uploading files in Universal Dashboard.
The UDUpload component is used to upload files to Universal Dashboard. You can process files the user uploads. You will receive the data for the file, a file name and the type of file if it can be determined by the web browser.
This component works with and .
Uploads a file and shows the contents via a toast.
The body of the OnUpload
script block is a JSON string with the following format.
The $EventData
is an object with the following structure.
Uploads a file as part of a UDForm.
The body of the OnSubmit
script block is the same one you will see with any form and the file will be contains as one of the fields within the form.
This example allows a user to upload a file. Once the file is uploaded, it will be saved to the temporary directory.
Drag and drop layout designer.
The Grid Layout component is useful for defining layouts in a visual manner. You can drag and drop components using the web interface to automatically define the layout as JSON.
You can employ the -Design parameter to configure the layout of yourr page. This allows dynamic drag and drop of components that you place within the content of the grid layout. As you drag and resize components, the layout will be copied to your clipboard. Note: All components must possess a statid -Id
Once you have configured the layout to fit your needs, you can paste the JSON into your script and assign it with the -Layout parameter. Remove the -Design parameter to lock elements in place.
You can allow your users to dynamically modify layouts by using the -Draggable, -Resizable and -Persist parameters. The layout changes are stored locally so the next time each user visits a page, it will be loaded with their chosen layout.
Tab component for Universal Dashboard
Tabs make it easy to explore and switch between different views.
Tabs organize and allow navigation between groups of content that are related and at the same level of hierarchy.
Dynamic tabs will refresh their content when they are selected. You will need to include the -RenderOnActive
parameter to prevent all the tabs from rendering even if they are not shown.
New-UDMenu component for Universal Dashboard.
Available in PowerShell Universal 2.5 or later.
The menu component can be used to provide a drop down list of options for the user to select.
Create a basic menu.
You can edit the style of the menu by adjusting the variant parameter.
You can use the value parameter to define a value that differs from the text displayed.
Use the -OnChange
parameter to specify a script block to call when a new value is selected. The value of the selected item will be available in $EventData
.
Quickly and responsively toggle the visibility value of components and more with the hidden utilities.
Hidden works with a range of breakpoints e.g. xsUp
or mdDown
, or one or more breakpoints e.g. -Only 'sm'
or -Only @('md', 'xl')
. Ranges and individual breakpoints can be used simultaneously to achieve very customized behavior. The ranges are inclusive of the specified breakpoints.
Using any breakpoint -Up
parameter, the given children will be hidden at or above the breakpoint.
Using any breakpoint -Down
parameter, the given children will be hidden at or below the breakpoint.
Using the breakpoint -Only
parameter, the given children will be hidden at the specified breakpoint(s).
The -Only
parameter can be used in two ways:
list a single breakpoint
list an array of breakpoints
Stepper component for Universal Dashboard
Steppers convey progress through numbered steps. It provides a wizard-like workflow.
Steppers display progress through a sequence of logical and numbered steps. They may also be used for navigation. Steppers may display a transient feedback message after a step is saved. The stepper supports storing input data in the stepper context. It supports the following controls.
The $Body variable will contain a JSON string that contains the current state of the stepper. You will receive information about the fields that have been defined within the stepper and info about the current step that has been completed. The $Body JSON string will have the following format.
You can validate a step in a stepper by specifying the OnValidateStep
parameter. The script block will receive a $Body variable with JSON that provides information about the current state of the stepper. You will need to return a validation result using New-UDValidationResult
to specify whether the current step state is valid.
The JSON payload will have the following format. Note that steps are 0 indexed. If you want to validate the first step, check to make sure the step is 0.
You will have to convert the JSON string to an object to work with in PowerShell and then return the validation result.
You can direct the user to a particular step in the OnValidateStep
event handler. Use the New-UDValidationResult
-ActiveStep
parameter to move the user to any step after clicking next. Step indices are 0 based.
This example moves the user to the last step after completing the first step.
You can disable the previous button by using the -DisablePrevious
parameter of New-UDValidationResult
.
This example disables the previous step whenever the user moves forward in the stepper.
You can create a vertical stepper by setting the -Orientation
parameter to vertical.
Grid layout component for Universal Dashboard.
The responsive layout grid adapts to screen size and orientation, ensuring consistency across layouts.
The grid creates visual consistency between layouts while allowing flexibility across a wide variety of designs. Material Design’s responsive UI is based on a 12-column grid layout.
Adjust the spacing between items in the grid
You can also use the New-UDRow
and New-UDColumn
functions when working with the grid.
Protect sections based on roles.
The Protect-UDSection
cmdlet hides it's content if a user does not have the specified roles.
Paper component for Universal Dashboard
In Material Design, the physical properties of paper are translated to the screen.
The background of an application resembles the flat, opaque texture of a sheet of paper, and an application’s behavior mimics paper’s ability to be re-sized, shuffled, and bound together in multiple sheets.
By default, paper will have rounded edges. You can reduce the rounding by using a square paper.
The -Style
parameter can be used to color paper. Any valid CSS can be included in the hashtable for a style.
The following example creates paper with a red background.
AppBar component for Universal Dashboard
The App Bar displays information and actions relating to the current screen.
The top App Bar provides content and actions related to the current screen. It's used for branding, screen titles, navigation, and actions.
To create an app bar that is pinned to the bottom of the page, you can use the -Footer
parameter.
A fixed AppBar will show even when the screen is scrolled. It will remain stuck to the top. This example creates an AppBar that is fixed with a div that is 10000 pixels high.
Card component for Universal Dashboard
Cards contain content and actions about a single subject.
Cards are surfaces that display content and actions on a single topic. They should be easy to scan for relevant and actionable information. Elements, like text and images, should be placed on them in a way that clearly indicates hierarchy.
Although cards can support multiple actions, UI controls, and an overflow menu, use restraint and remember that cards are entry points to more complex and detailed information.
You can use the body, header, footer and expand cmdlets to create advanced cards. The below example creates a card with various features based on a Hyper-V VM.
Transition component for Universal Dashboard.
Transitions allow you to transition components in and out of view within your dashboard using various animations. You can take advantage of interactive cmdlets like Set-UDElement
to change the transition state and cause an element to move in.
In the following example, we have a card that transitions in via a Fade. Clicking the switch the toggle the card in and out.
The resulting effect looks like this.
The collapse transition will collapse a section in and out. You can specify a collapse height to only collapse a portion of the section.
A fade transition fades a component in and out as seen in the previous example. You can configure the timeout value to specify the number of seconds it takes to complete the transition.
The slide transition moves a component into position. You can determine the position of the slide by specifying the -SlideDirection
parameter.
The grow transition will fade and grow a component into place.
The zoom transition will zoom a component into place.
Role based access for dashboards.
This feature requires a license.
When dashboard authentication is enabled, you can define the role that a user must be a part of in order to access the dashboard. Roles are configured on the Settings Security page or from within the roles.ps1
configuration file.
If a user attempts to visit a dashboard that they do not have access to, they will be presented with a Not Authorized page.
You can also show or hide pages based on roles. To define a role for a page, use the -Role
parameter of New-UDPage
. Only users of the specified role will have access to this page.
In addition to dashboard and page roles, you can also check with roles a user is a part of by using the $Roles
variable that is available within Dashboards. This variable contains an array of the roles that are assigned to the user.
For example, you could show the Restart-Computer
button to only Administrators.
Expansion Panel component for Universal Dashboard
Expansion panels contain creation flows and allow lightweight editing of an element.
An expansion panel is a lightweight container that may either stand alone or be connected to a larger surface, such as a card.
Universal Dashboard exposes two custom variable scopes using custom providers. These providers allow you to store your variables in scopes that make sense for a web application. The cache scope is used to store variables that can be used within any endpoint inside a dashboard. The session scope is used to store variables that can be used for a single user's session of the dashboard.
Cache scope is used to store a variable that will be available in any endpoint. Cache scope is useful for storing data that may be shown in more than one control or may be time consuming to look up. This could be helpful for querying machine performance counters (e.g. Active Directory, Azure).
Just like any other scope, cache variables are defined with a prefix and a colon separator.
Once assigned, the $Cache:Computer
variable is available within any endpoint.
Page scope stores variables in per browser tab or window. If a new tab is opened or the current one is closed, the state will be removed.
Session scope is used to store a variable per session. A session is established when a user's browser first visit a dashboard. A cookie is stored in the user's browser that dictates that it is part of the session. Sessions have an idle timeout of 25 minutes.
Just like any other scope, cache variables are defined with a prefix and a colon separator.
Once assigned, the $Session:ShowChart
variable is available in dashboard endpoints. Session variables are not available in REST API endpoints or scheduled endpoints.
Once a session is terminated, the session variables are cleared.
Simple scheduled endpoints within dashboards.
We recommend you consider over scheduled endpoints for jobs that require tracking of output, input, history or complex scheduling rules.
Scheduled endpoints allow you to run PowerShell script blocks on a schedule within your dashboards. Scheduled endpoints are more light weight than scheduled jobs but do not provide the same level of functionality. They do not track any history, the output is not logged and the schedules are not visible within the UI.
Scheduled endpoints are useful when loading and caching data that you will only use in your dashboard. Data stored within the dashboard cache is not shared across PowerShell Universal.
The below is an example of scheduling an endpoint that runs every 10 seconds and stores information in a cache variable. This type of configuration increases performance of the dashboard for end users since the cache data is returned rather than calling Get-Process with each load of the dashboard.
You can also use thecaching features in dashboards. This means that you will be able to access that data throughout PowerShell Universal scripts. In your dashboard, you can load the cache with the scheduled endpoint.
You can then use the cache data in your API.
Information about user sessions.
Universal Dashboard maintains sessions for users within each dashboard. There are several locations you can configure user session information.
Session settings for a dashboard are using the web server session setting by default. You can set the dashboard session timeout for an individual dashboard by using the -SessionTimeout
of New-PSUDashboard
. The timeout value is in minutes.
Dashboard sessions are sliding and will not expire while the window is open and active. Some browsers will pause tabs which will cause the session to expire after the time out.
Restarting a dashboard will cause all sessions to disconnect.
The web server will maintain a session for the user. The session is sliding and will not expire while the window is open and active. Some browsers will pause tabs which will cause the session to expire after the time out.
The default value for the web server session timeout is 25 minutes. You can change the web server session setting by updating the appsettings.json
file.
In addition to dashboard session timeout, you can also timeout the dashboard when it is idle. Even if the window is open, if the user does not click, type or move the mouse for the idle timeout period, the window will time out. This functionality is disabled by default.
You can set the idle timeout in minutes by setting the -IdleTimeout
parameter of New-PSUDashboard
cmdlet.
IIS can cause timeouts of sessions in numerous ways. You will need to configure your application pool settings to avoid recycling which will cause all dashboard sessions to be removed.
Within the advanced settings dialog for the application pool, you can set the recycling settings accordingly.
Use cascading style sheets with Universal Dashboard.
You can use a cascading style sheet (CSS) by add a .css
file to a published folder and then passing it to the -Stylesheets
parameter for New-UDDashboard
.
For example, the dashboard.ps1
file would look like this.
You could then setup a published folder to provide the assets route. This is what the contents of publishedFolders.ps1
will look like.
Within the C:\assets
folder, you can place any assets you'd like to access on the /assets
route.
You can then create a style sheet to manipulate whatever portion of the dashboard you'd like.
This produces a dashboard with a background image of Austin the dog sleeping in a pile of dirt.
Every Material UI component has a series of global class names that you can use to apply styles throughout your dashboard. To determine the correct class names, you can view the a particular component's API documentation. There is a list of the global class names that apply to that component.
Within your CSS file, you can use these class names to override styles throughout your dashboard. If you wanted to set all success alerts to have a red background, you could create a CSS file like this.
The page shows how to use the Universal Dashboard marketplace.
The is a PowerShell Gallery module aggregator. It synchronizes with the PowerShell Gallery on an hourly basis to find modules that can be used with Universal Dashboard.
Within PowerShell Universal, you can access the Universal Dashboard Marketplace by navigating to the Dashboards page and clicking the Marketplace button in the top right.
Once installed, the component will be listed on the Dashboard Components page. You can access this by clicking Dashboards and then the Components button in the top right.
To add the component to a dashboard, navigate to the Dashboard Details and then click the Add Component button.
The drawer will show which components are already added and which components can be added. Click the add button to activate the component for the dashboard.
You can install any of the components from the Marketplace by using the Install-Module
or Save-Module
cmdlets provided by PowerShellGet
. Since the components are just listed on the PowerShell Gallery, you'll be able to use their module name during install.
Depending on how the components were installed, you may need to import the module in your dashboard file.
Interaction features of Universal Dashboard
Universal Dashboard enables the ability to create interactive websites with PowerShell. There are several cmdlets that have been implemented to provide feedback to the user, update components and read the state of components.
You can set string data into the user's clipboard with Set-UDClipboard
.
You can start a download within the user's browser by using Start-UDDownload
. Due to security of web browsers, the user will need to take an action (like click a button) to allow the download to take place. Start-UDDownload
is not suited for large file downloads.
Many components support event handlers in the form of script blocks. You may also see these referred to as endpoints as that is what they were called in Universal Dashboard v2. These event handlers allow you to invoke PowerShell scripts when certain actions take place on the page.
For example, you may have a button click that calls an event handler. This button will show a toast when clicked. You can include any valid PowerShell cmdlet within the event handler code.
Variables are automatically scoped into event handlers. You will be able to access variables that you define outside of the variable within the event handler.
Some event handlers handlers will provide data as a string or as a hashtable. This depends on the event handler you are using. For example, the New-UDButton
-OnClick
event handler does not provide any data. On the other hand, the New-UDSelect
-OnChange
will provider event data.
You can access the event data by using the $Body
variable to access the data as a string (sometimes formatted as JSON) or as a hashtable by using the $EventData
variable.
You can force a form to submit using the Invoke-UDForm
cmdlet. You can optionally chose to enforce validation by including the -Validate
parameter.
You can force a form to validate by using Test-UDForm
.
You can invoke JavaScript from PowerShell by using the Invoke-UDJavaScript
cmdlet.
You can use the Show-UDToast
cmdlet to create a toast message that will appear on the end user's webpage. It happens over a websocket and will show the toast immediately as it is called.
Toasts support icons as strings. You can use all the FontAwesome v5 icons.
Hides a toast based on the specified ID.
You can redirect users to different pages using the Invoke-UDRedirect
cmdlet. It happens over a websocket and will redirect as soon as the cmdlet is called.
Invoke-UDRedirect
will automatically redirect to pages in the dashboard when using a relative path.
If you'd like to redirect to a local path outside of the dashboard, you can use the -Native
parameter.
You can open a modal using the Show-UDModal
cmdlet. It will open as soon as you call it. You can include whatever components you like within the modal.
You can manage component state dynamically by using the UDElement commands.
You can receive the state of an element using Get-UDElement
. The state will be returned as a hashtable. This is primarily useful for input components.
Alternatively, you can set component state using Set-UDElement
. You will need to specify an ID and a hashtable of properties to set on the component. All built in components support Set-UDElement.
You can remove components from the page using Remove-UDElement
. The component will no longer appear on the page.
Add a child component to an existing parent component.
You can remove all the children components from an component by using Clear-UDElement
.
Some components support reloading. You can trigger a reload of a component using Sync-UDElement
.
You can select a component with Select-UDElement
.
Dashboards integrate directly with the PowerShell host to provide features based on standard cmdlets.
Using the Read-Host
cmdlet will cause a dialog to show on the user's dashboard. The text entered will be returned by the cmdlet.
Using Get-Credential
will cause a dialog to show that accepts a username and password. A PSCredential
object will be returned from the cmdlet.
Cmdlets that use the progress stream or the use of the Write-Progress
cmdlet will result in a progress dialog being shown. The popup will show the activity, percent completed and current operation.
You can disable the Write-Progress integration by setting the $ProgressPreference
to SilentlyContinue
.
You can use the $Host.UI.PromptForChoice
function to display a multi-select dialog.
For example, here is the .
You can follow the directions on the page on how to publish components to the Universal Dashboard Marketplace.
Read more about .
PowerShell Universal Dashboard v2.9 is a PowerShell module that allows you to create dashboard with PowerShell script. It is the predecessor to PowerShell Universal. The technology the enabled UD has been migrated into PowerShell Universal. You should be able to run the same PowerShell scripts in PowerShell Universal that you would in Universal Dashboard with some minor modifications.
When looking at the Universal Dashboard v2 documentation, you can click the link at the top of each page to take you to the corresponding documentation for PowerShell Universal.
In Universal, all you need to do is return the result of New-UDDashboard from your script. There is no need to call Start-UDDashboard. The configuration of the webserver is taken place using the PSU appsetting.json
file.
This cmdlet has been removed from Universal Dashboard. There is no longer a need to call it.
You do not need to pass the value of a scheduled endpoint to anything. You can just call New-UDEndpoint
with a endpoint schedule and it will automatically be registered with PSU.
To learn more about APIs, click here.
Authentication and authorization are now handled by PSU and there is no need to configure UD login pages. Authentication and authorization are configured with the PSU appsettings.json
file. Dashboard's themselves can be either authenticated or not authenticated. A license is required to enable authenticated dashboards.
To enable role-based access controls, you can assign roles to pages and use the automatic $Roles
variable to check which roles the user is a part of. The $User
variable will provide the name of the user.
Authorizations policies in Universal work very similar to the ones in Universal Dashboard, you will define them using the New-PSURole
cmdlet. When you define the role, you have the option to define a policy that will assign that role automatically to a user.
For example, let's adjust a claims policy from Universal Dashboard for Universal.
Universal Dashboard
Universal
Much like the Get-UDAuthorizationPolicy
cmdlet in Universal Dashboard, you also have access to the assigned roles for users in Universal. Simply check the $Roles
variable to see which roles the user has.
Click here to learn more about Published Folders in PowerShell Universal.
This section contains migration information for upgrading from UDv2 to UDv3. They are vastly different frameworks and will require rewriting your dashboard. Many of the concepts are the same.
Pages have a different behavior in v3. All pages are dynamic pages. This means that you don't have to worry about whether a page will be generated at run time or doing start up. Pages are always generated during runtime.
If you have a page such as this one:
You can convert it to a v3 page by changing the syntax to:
Rather than having two cmdlets for tables (New-UDTable and New-UDGrid). The New-UDTable in v3 provides the ability to display data in a table, filter, page, and sort it. It supports both client and server-side processing.
You can view examples of the table on GitHub.
Unlike in v3, components do not have -Endpoint
and -Content
parameters. Each component will instead simply have a -Content
parameter. To achieve dynamic sections of a page, you can instead use the New-UDDynamic
cmdlet. This cmdlets let you define an entire section of a page as dynamic. It also provides auto refresh functionality so you can refresh sections of a page all at once.
New-UDGrid allows you to define a grid layout using the Material UI library. You use this single cmdlet to define rows and columns within your dashboard.
You can view examples of the grid on GitHub.
New-UDInput
has been replaced by New-UDForm
. The UDForm component allows far more configuration that UDInput did. You will use the standard controls like UDTextbox, UDCheckbox, and UDSelect instead of New-UDInputField. This means that there are a single set of input cmdlets to use for UD.
All of the input control examples can be found on GitHub.
Instead of using New-UDSideNav, you will now use a combination of New-UDAppbar and New-UDDrawer. When New-UDAppBar is used with the default position, it will overlay the AppBar at the top of the page. You can then specify a drawer to customize the navigation experience within your dashboard.
You can see examples of how to do navigation on GitHub.
The Nivo and sparklines controls are now open source and on the Universal Dashboard repository. You can now use them without purchasing a license.
For more examples of Nivo and sparklines controls, see GitHub.
The map control is also open source and on GitHub.
You can find examples on GitHub.
Universal Dashboard v3 is built on Material UI. Material UI provides a built-in theme system that UD now takes advantage of. You can utilize this theme system by providing a hashtable of options to the New-UDDashboard
's -Theme
parameter.
Here's an example of changing the theme's main color.
Note that when specifying keys that require a number, ensure that the key is specified as a string.
You can set the default theme to either Light or Dark using the -DefaultTheme
parameter.
You can change the page background color by setting the background default color. To adjust the header background color, set the primary main color.
To support dark and light palettes, you can define a dark and light sections in your hashtable. They have the same properties as a theme.
To change the font size, set the typography fontSize property.
For a full list of options available for the theme system, you can look at the default theme for Material UI.
You can override any component CSS value using the theme engine. In order to override a component's base theming, you will need to identify the CSS class name applied to that element.
To identify a component's CSS classes, use the developer tools of your browser. Right click on the component you wish to style and click Inspect Element.
This will highlight the HTML elements that make up that component. In the image below, you will see we have numerous CSS classes being applied such as:
MuiButtonBase-root
MuiButton-root
MuiButton-label
MuiTouchRipple-root
In order to override these various elements, you will need to add an overrides
key to your theme.
Next, you'll need to add keys to the overrides for each element you wish to modify. Notice that I have not included the portion of the class name after the hyphen.
Now, add the subitems you wish to modify to the class name.
The last step is to define the CSS properties you wish to apply to elements that use these classes.
For more examples, look at the Onepirate and Paperbase themes below that include many component overrides.
Based on the Material UI theme, Onepirate.
The dashboard used to generate the above image is included below.
Based on the Material UI theme, Paperbase.
This the dashboard used to create the above image.
UDStyle component for Universal Dashboard
You can apply styles to individual components within Universal Dashboard by using the UDStyle
component. This component will need to be added to your dashboard and is part of the core components included with PowerShell Universal.
To apply a style to a component or a set of components, you call the New-UDStyle
cmdlet, specify a CSS style and then include the components you wish to style within the -Content
script block.
Each Material UI component has a set of built in classes that you can override using New-UDStyle
. To determine the class names that you need to override, you can view the API documentation for the component you are trying to modify on the Material UI site. For example, here is a listing of the Alert component's CSS class names.
When using a success alert, you will have the .MuiAlert-standardSuccess
class applied to your component. You can override this default style like this.
The resulting alert will be red instead of the default green.