controls/job-tree.ps1
function New-UDJobTree { param($Tree) $Parameters = @{ ID = $Id Name = "$($Tree.Script.Name) ($Id)" } if ($Tree.Children.Length -gt 0) { $Parameters["OutPort"] = "<" } $RootNode = New-UDDiagramNode @Parameters $Script:Nodes = @() $Script:Nodes += $RootNode $Script:Links = @() function New-NodesAndLinks { param($Node, $Depth) $yOffset = 0; foreach($child in $Node.Children) { $Parameters = @{ ID = $child.Id Name = "$($Child.Script.Name) ($($child.Id))" InPort = ">" } if ($child.Children.Length -gt 0) { $Parameters["OutPort"] = "<" } $NewNode = New-UDDiagramNode @Parameters -xOffset ($Depth * 100) -yOffset $yOffset $Script:Nodes += $NewNode $Link = New-UDDiagramLink -OutNode $Node.Id -InNode $NewNode.Id -OutPort "<" -InPort ">" $Script:Links += $Link New-NodesAndLinks -Node $child -Depth ($Depth + 1) $yOffset += 100; } } New-NodesAndLinks -Node $Tree -Depth 1 $Parameters = @{ Node = $Script:Nodes } if ($Script:Links.Length -gt 0) { $Parameters["Link"] = $Script:Links } New-UDCard -Title 'Job Tree' -Content { New-UDDiagram @Parameters -Locked } } |