Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Simple, drag and drop web pages that can execute PowerShell and REST APIs.
Pages allow you to create basic websites that do not require any coding of the user interface. You can drag and drop UI components on to the designer and set properties of each component. Components can interact with APIs and Scripts that are defined within Universal.
To add a page, navigate to User Interfaces \ Pages within the admin console. Click the Create New Page button to create a page.
The name of the page will also be the URL used to access the page.
Pages can take advantage of role based access. You can turn on authentication for a page and limit the access to the page to users based on role. This feature requires a license.
To edit the content of the page, you can view the page as an administrator. When you view the page, you will have access to an edit button for managing the components and layout of the page.
To add a component, click the Toolbox button and select the component to add. Properties for a component can be set by clicking the properties button on the component and editing the required and optional properties.
Layouts are setup by resizing and dragging components around the designer surface. Layouts are responsive. If you want to setup layouts for smaller screens, reduce the width of your window and setup a new layout.
Certain components can interact with scripts or API endpoints. These include buttons, forms, statistics and tables. You can configure the script or API that is invoked as well as the parameters that are passed to those targets.
This example uses a script to populate a table.
This example invokes a script when a button is clicked.
Grouping pages will create nested navigation within the page section. Select a group in the page properties. Matching pages will be displayed in that group.
By default, the page URL will be the Name of the page. So for example, if the page's name was Services the URL will be /Services
.
You can customize the URL in the page properties.
You can change the default URL of the PowerShell Universal instance by setting the page URL to /
. When users login or visit the server name directly, they will not be directed to /admin
but rather the page defined with /
.
Pages are stored as XML. Unlike dashboards, they do not allow for direct programmatic configuration. The layout and components are static but can interact with APIs and scripts.
Forms that can be invoked to call scripts and APIs.
Forms can be used to invoke scripts. The form component ties directly into the automation features to allow for the display of output, progress and respond to feedback.
To invoke a script, select the target of Script and the script you'd like to invoke.
By default, no output or progress will be shown. The form will simply consist of a Save button.
If the script succeeds, you'll see a success result. If it fails, it will return a failure result.
You can view the output as the script runs by using the Show Output check box.
To view the output of cmdlets like Write-Progress
, you can use the Show Progress check box. While the script executes, you'll see the progress messages.
The script in this example simply shows progress.
To view the output of the script after it has run, you can use the Result Type drop down. The Text result type, will display output as text.
To view output as a table, select the result type of Table.
Scripts that request feedback will prompt the user to enter more information.
An example of a script that may request feedback is one that uses Read-Host
Invoking an API with a form can be done by selecting API from the Target Type and then selecting the API endpoint you wish to call.
API endpoints do not support progress, feedback, or output while running the API. They do support returning results as text or tables. APIs that return 200 will show a Success result and other status codes will return Failure.
Fields provided to an API endpoint will be sent as a single JSON object with properties for each field.
For example, if you had a form with a field named txtName and txtLastName, you could access those properties by deserializing the $Body
variable.
You can specify fields for each form. Currently forms support text boxes, checkboxes and hidden values. Fields can have a tooltip description and marked as required.
Fields are provided to scripts as parameters. You can use a param
block to capture these field values.
For example, if you had a FirstName and LastName field, you would define the following param block in your script.
Fields are provided to APIs as a JSON body to the POST endpoint. Each field will be a property of the JSON object passed to the API.
The checkbox field provides a checkbox the user can select and $true
or $false
will be sent to the target.
Date
Allows the user to select a date. The value will be passed as a string.
Hidden fields provide a value to the target that is not shown to the user. The value will be a string.
Number
Allows the user to select a number. The value will be passed as an integer.
Password
Available in PowerShell Universal 2.5 or later
A textbox with a mask to prevent you from seeing the characters typed.
Select
Allows the user to select an option from a drop down. The value will be passed as a string.
Switch
Allows the user to provide a true or false. The value will be passed as a boolean.
The textbox field allows the user to enter any text into the field and it will be submitted to the target. The value will be a string.
Time
Allows the user to select a time. The value is passed as a string.
Rating
Allows the user to select a rating between 0 and 5. The value is passed as a float.
You can customize the text of numerous features of a field including the success and failure text, waiting on feedback text and button text.
Available in PowerShell Universal 2.9 or later.
You can validate a form by selecting an API endpoint from the Validation API field. The validation endpoint must be a POST method. Use the New-PSUValidationResult
parameter to return whether the validation is successful.
Smart properties are hashtables included in the data returned from APIs and Scripts. Tables will automatically translate these hashtables to rendered components when displaying them.
You can include links by using a hashtable with the link
type and providing a url
and text
property.
You can include images by using a hashtable with the image
type and specifying any valid img
HTML attributes.
Liquid charts show a percentage value as returned by an API or script.
An API that provides data to a chart needs to return a single number between 0.0 and 1.00.
This example returns a random percentage.
Select an API from the list of available APIs.
The liquid chart will display the value.
You can display a liquid chart with data from a script. You should return a single value between 0.0 and 1.00.
This script we are executing in this example returns a random percentage.
Select the script as the data source.
The chart will display based on the data returned.
Card component for Pages.
Cards contain a title and content text.
You can load data from an API endpoint or job. The data properties will be available as variables within your text.
For example, if you may have an endpoint that returns data like the following.
You could then use the following variables within the title and content text.
A line chart that can display output from scripts and APIs.
Line charts can retrieve output from scripts and APIs to display the data in a chart.‌
You will need to return an array of JSON objects from your API in order to use a bar chart. An example would be returning a list of hashtables serialized to JSON.
In this example, you would configure the data source to an API and select your API endpoint.
You would then specify Name as the X axis and Value as the Y axis.​​
The resulting chart contains the data from the API. Each time the page is loaded, the API is called.​
You will need to return PSCustomObjects, objects or hashtables from your script in order to display a chart from a script.
You will need to set the data source to script and select the script you want to retrieve data for.​
You will need to set the Y and X axis to the properties of the object returned from the script.​‌
The chart will appear on the page like this. Loading the page will not call the script again. It will load the result of the last time the script ran.​
‌
Display image on a page.
Images are simple components that just display an image on the page.
A button that can be used to invoke a script or API.
You can invoke a script with a button. This will allow you to specify arguments, environment and run as credentials for the script.
Set the target of the button to script and select the script you would like to use. You can then select the environment and run as credentials. Finally, specify parameters to pass to the script.
Clicking the button will run the script and show a toast notification after the click.
Set the target to API and select the endpoint that you want to invoke. The endpoint must be a POST endpoint. Parameters can be specified. Parameters will be passed as part of a JSON object.
Buttons support customizing the text and icon shown within the button.
A bar chart that can display output from scripts and APIs.
Bar charts can retrieve output from scripts and APIs to display the data in a chart.
You will need to return an array of JSON objects from your API in order to use a bar chart. An example would be returning a list of hashtables serialized to JSON.
In this example, you would configure the data source to an API and select your API endpoint. You would then specify Name as the Y axis and Value as the X axis.
The resulting chart contains the data from the API. Each time the page is loaded, the API is called.
You will need to return PSCustomObjects, objects or hashtables from your script in order to display a chart from a script.
You will need to set the data source to script and select the script you want to retrieve data for.
You will need to set the Y and X axis to the properties of the object returned from the script.
The chart will appear on the page like this. Loading the page will not call the script again. It will load the result of the last time the script ran.
Properties
Description
Available Since
Id
The ID of this component
2.2.0
Data Source Type
The data source type for this chart. Accepts scripts or APIs.
2.2.0
Data Source
The data source for this chart.
2.2.0
Color
The color of the chart.
2.2.0
Property
Description
Available Since
Id
The ID of this component
2.2.0
X Axis Field
The field to use as the X Axis for data within the chart.
2.2.0
Y Axis Field
The field to use as the Y Axis for data within the chart.
2.2.0
Data Source Type
Whether to use a script or API as a data source.
2.2.0
Data Source
The script or API to use as data for the chart.
2.2.0
Color
The bar color to use for the chart.
2.2.0
Property
Description
Available Since
Id
The ID of this component
2.2.0
URL
The URL of the component. This can be a relative URL to an image stored in a Published Folder.
2.2.0
Property
Description
Available Since
Id
The ID of this component
2.2.0
Target Type
The type of target. Supports Script and API.
2.2.0
Target
The script or API to invoke.
2.2.0
Run As
The run as credential to use when invoking a script. Not used for APIs.
2.2.0
Environment
The environment to run the script within. Not used for APIs.
2.2.0
Parameters
Name value pairs of parameters. For scripts, they are passed as parameters. For APIs, they are passed as a single JSON object.
2.2.0
Text
The text to display within the button
2.2.0
Icon
The icon to display within the button
2.2.0
Toast on Success
Shows a success toast message when the button successfully calls the target.
2.2.0
Toast on Error
Shows a failure toast message when the button fails to call the target.
2.2.0
Property
Description
Available Since
Id
The ID of this component
2.2.0
X Axis Field
The field to use as the X Axis for data within the chart.
2.2.0
Y Axis Field
The field to use as the Y Axis for data within the chart.
2.2.0
Data Source Type
Whether to use a script or API as a data source.
2.2.0
Data Source
The script or API to use as data for the chart.
2.2.0
Color
The bar color to use for the chart.
2.2.0
Scrollbar
Whether to display a scrollbar when there are many items in the chart.
2.2.0
Alerts show colored text and icons to notify users.
Iframe component for PowerShell Universal pages.
Available in PowerShell Universal 2.5 or later.
Iframes provide the ability to nest another website within the page. The is especially useful if you wish to embed a dashboard within a page.
To embed a dashboard in a page, assume we have a dashboard that is defined such as this. This dashboard returns a table of services. It uses the -Blank
parameter on New-UDPage
to remove the header. This dashboard is configured with a base URL of /embed
Add a new IFrame component to the page and within the properties of the page, set the URL to the base URL of the dashboard.
When the page loads, it will load the dashboard and display it within the page.
When you embed multiple dashboards within a page they will be treated an individual dashboards and will not communicate event handling code. This means that display toasts and modals will appear within the IFrame and not in the parent code.
Display text is various paragraph forms.
Paragraphs display text with different styles depending on properties.
Property
Description
Available Since
ID
The ID of this component
2.2.0
Value
The text to display within the paragraph.
2.2.0
Code
Whether to display as code.
2.2.0
Copyable
Whether the text is copyable
2.2.0
Type
The type of text to display. Supports Default, Secondary, Success, Warning, and Danger
2.2.0
Table component for PowerShell Universal pages.
Tables allow you to display the output of APIs and scripts in rows and columns. Each object returned by the data source will create a row within the table. You can customize the columns of the table.
Both APIs and Scripts are supported by tables. When selecting an API, the API will be executed each time the page is loaded. When selecting a script, the last job run of the script will provide the output.
When columns are not defined, all the properties of the objects will be displayed.
You can customize the columns that are selected when displaying data.
Basic columns will select the properties defined and display the text.
In this example, we are selecting the name and service type from a call to Get-Service
.
The resulting table only has these two properties displayed.
Buttons can be added to columns to provide functionality for each row. Clicking the button will provide the target with the row data via the $InputObject
parameter.
Displays a numeric statistic on a page.
Numeric statistics can return data from scripts and APIs and display values with some amount of formatting options.
APIs should return a single value to display as a statistic. An example API could look something like this.
You can then select the API under the data source tab.
Each time the page is loaded, the API is called and the random value is shown.
Statistics shown from scripts will display the value return by the last job run for the script. Loading the page will not run the script again.
We will use this script as an example.
Select the script on the data source tab.
The statistic will be shown on the page based on the output of the script. You'll notice that refreshing the page does not change the value of the statistic unless the job is run again.
You can customize features such as the prefix, suffix, precision and whether to auto-reload the statistic on an interval.
Property
Description
Available Since
ID
The ID of this component
2.2.0
Title
The text to display within the statistic.
2.2.0
Data Source
The script or API to call to return the statistic's value.
2.2.0
Prefix
The string to display before the value.
2.2.0
Suffix
The string to display after the value.
2.2.0
Auto Reload
Whether to auto-reload the statistic on an interval.
2.2.0
Auto Reload Interval
The number of seconds between auto-reloads.
2.2.0
Precision
The number of decimal places to display in the value.
2.2.0
Variables available in PowerShell Universal pages.
This feature requires a PowerShell Universal license.
Variables allow you modify the functionality of a page depending on factors such as the user name or URL route. Variable-based routes allow you to create dynamic pages based on the URL the user is visiting.
Variables that are defined with Platform \ Variables will also be available to pages.
Variables can be viewed when editing a page. To view variables, click Edit and then Variables.
A drawer will appear with the variables for the current page.
Variables can be used anywhere you can type a property value. For example, if you have an Alert, you could use the $pagename
variable within the title property.
When the page is rendered, the variable will be replaced.
You can also use variables within targets and data sources. This allows you to call URLs that will change based on the variable.
You can also use variables to provide hidden input fields to APIs and scripts.
You can load additional data when the page is loading by providing a data source to in the page properties. The data source should return a single PSCustomObject or hashtable. The properties of the object will become variables within the page.
For example, assume you have an API that returns the following hashtable.
Selecting this API as the data source for the page would then create the variables $Name
and $Title
within the page.
You can also use Route Variables within the data source to customize which API is called based on the route visited.
Route variables need to be defined when creating the URL for the page. Each section of the URL that starts with :
will be treated as a variable.
For example, this page defines a single route variable.
Within the page, the route variables will appear within the variable drawer.