Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created August 5, 2018 16:57
Show Gist options
  • Save adamdriscoll/7a805a66d3888234e51318f700ee769a to your computer and use it in GitHub Desktop.
Save adamdriscoll/7a805a66d3888234e51318f700ee769a to your computer and use it in GitHub Desktop.
Tree View
$Root = New-UDTreeNode -Name 'FileSystem' -Id 'FileSystem'
New-UDTreeView -Node $Root -OnNodeClicked {
param($Body)
$Obj = $Body | ConvertFrom-Json
if ($Obj.NodeId -eq 'FileSystem') {
Get-PSDrive -PSProvider FileSystem | ForEach-Object {
New-UDTreeNode -Name $_.Root -Id $_.Root
}
} else {
Get-ChildItem -Path $Obj.NodeId | ForEach-Object {
New-UDTreeNode -Name $_.Name -Id $_.FullName
} | ConvertTo-JsonEx
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment