Example 4
In this example, servers are grouped in a cluster (SubGraph).
The SubGraph (part of PSGraph module) feature groups the three servers into a dashed rounded rectangle labeled "3 Tier Concept," visually encapsulating the Web, Application, and Database servers along with their connections.
[CmdletBinding()]
param (
[System.IO.FileInfo] $Path = '~\Desktop\',
[array] $Format = @('png'),
[bool] $DraftMode = $false
)
Starting with PowerShell v3, modules are auto-imported when needed. Importing the module here ensures clarity and avoids ambiguity.
Since the diagram output is a file, specify the output folder path using $OutputFolderPath.
The $MainGraphLabel variable sets the main title of the diagram.
This section introduces the Subgraph feature, which allows grouping nodes together. In this example, all servers are grouped within a cluster named "3tier".
A SubGraph groups objects in a container, like a graph within a graph. SubGraph attributes allow you to set background color, label, border color, style, etc.
https://psgraph.readthedocs.io/en/latest/Command-SubGraph/
Finally, call the New-Diagrammer cmdlet with the specified parameters.
New-Diagrammer -InputObject $example4 -OutputFolderPath $OutputFolderPath -Format $Format -MainDiagramLabel $MainGraphLabel -Filename Example4 -LogoName "Main_Logo" -DraftMode:$DraftMode
When you run the script, it generates a PNG file named Example4.png in the specified output folder.
Resulting diagram: