Had a question about dynamically adding children to a treeview, not sure if it is even possible. I have a customer that would like a treeview representation of a section of their OU structure. I have this set up, which works just fine:
New-UDDashboard -Title "Hello, World!" -Content {
$aOUs = Get-ADOrganizationalUnit -SearchBase "OU=End-Users,DC=myDomain,DC=com" -Properties canonicalname -Filter * |
% {
[pscustomobject]@{
OUName = Split-Path $_.CanonicalName -Leaf
CanonicalName = $_.CanonicalName
}
}
New-UDTreeView -Node {
New-UDTreeNode -Name 'End-Users' -Children {
$aChildren = $aOUs | ? {(($_.CanonicalName).Split("/").Count -eq 3)} | Sort OUName
foreach ($child in $aChildren) {
New-UDTreeNode -Name "$($child.OUName)"
}
}
}
}
The code for getting the next layer of sub-OUs is done, but I am unsure if it is possible to dynamically insert more nodes at the correct level. I thought about using something along the line of Set-UDElement for each, but as they don’t have an Id am not sure that would even be possible. I also attempted to set an -Id on the main treeview, but when I look in ChroPath I do not see that property as I do for other elements such as buttons and text boxes, so guessing it does not accept that property.
Just curious if anyone has done something similar, or has any ideas how to populate the next level down.
Product: PowerShell Universal
Version: 1.5.16