Examples
Examples of things you can do with dashboards.

Display Processes

This example displays processes in a table.
New-UDDashboard -Title 'Processes' -Content {
$Processes = Get-Process | Select-Object Id, Name
New-UDTable -Columns @(
New-UDTableColumn -Property 'Id' -Title 'Id'
New-UDTableColumn -Property 'Name' -Title 'Name'
) -Data $Processes -ShowPagination
}

File System Browser

Create a file system browser with a dynamic tree view.
New-UDDashboard -Title 'Processes' -Content {
Get-PSDrive -PSProvider 'FileSystem' | ForEach-Object {
New-UDTreeView -Node { New-UDTreeNode -Name $_.Name -Id "$($_.Name):\" } -OnNodeClicked {
Get-ChildItem $EventData.Id | ForEach-Object {
New-UDTreeNode -Name $_.Name -Id $_.FullName -Leaf:$(-not $_.PSIsContainer)
}
}
}
}

Create User Form

This example shows how to create a local user account.
New-UDDashboard -Title 'New User' -Content {
New-UDForm -Content {
New-UDTextbox -Id 'UserName' -Label "User Name"
New-UDTextbox -Id 'Password' -Label 'Password' -Type 'password'
} -OnSubmit {
$Password = $EventData.Password | ConvertTo-SecureString -AsPlainText
New-LocalUser -Name $EventData.UserName -Password $Password
Show-UDToast "New user $($EventData.UserName) was created!"
}
}

Clock

This example shows how to create a clock component in PowerShell Universal Dashboard.
New-UDDashboard -Title 'Clock' -Content {
New-UDDynamic -Id 'clock' -Content {
(Get-Date).ToString('T')
} -AutoRefresh -AutoRefreshInterval 1
New-UDButton -Text 'Toggle Clock' -OnClick {
Set-UDElement -Id 'clock' -Properties @{
autoRefresh = -not( (Get-UDElement -Id 'clock').AutoRefresh)
}
}
}
Copy link
On this page
Display Processes
File System Browser
Create User Form
Clock