This example displays processes in a table.
New-UDApp -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
}
Create a file system browser with a dynamic tree view.
New-UDApp -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)
}
}
}
}
This example shows how to create a local user account.
New-UDApp -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!"
}
}
This example shows how to create a clock component in PowerShell Universal.
New-UDApp -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)
}
}
}