-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExample04.ps1
More file actions
76 lines (60 loc) · 3.67 KB
/
Example04.ps1
File metadata and controls
76 lines (60 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<#
Simple example of creating a 3-tier web application diagram using the AsBuiltReport.Diagram, without using object icons.
** In this example, servers are grouped in a cluster (SubGraph).
#>
[CmdletBinding()]
param (
[System.IO.FileInfo] $Path = '~\Desktop\',
[array] $Format = @('png'),
[bool] $DraftMode = $false
)
<#
From PowerShell v3 onwards, the module does not need to be explicitly imported. It is included here for clarity.
#>
# Import-Module AsBuiltReport.Diagram -Force -Verbose:$false
<#
As the diagram output is a file, specify the output folder path using $OutputFolderPath.
#>
$OutputFolderPath = Resolve-Path $Path
<#
The $MainGraphLabel variable sets the main title of the diagram.
#>
$MainGraphLabel = 'Web Application Diagram'
$example4 = & {
<#
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. (SubGraph is a reserved word in the PSGraph module)
https://psgraph.readthedocs.io/en/latest/Command-SubGraph/
#>
SubGraph 3tier -Attributes @{Label = '3 Tier Concept'; fontsize = 18; penwidth = 1.5; labelloc = 't'; style = 'dashed,rounded'; color = 'gray' } {
<#
This creates a diagram with three servers, custom node labels, and shapes (no object icons).
Node statements create the nodes in the diagram. (Node is a reserved word in the PSGraph module)
https://psgraph.readthedocs.io/en/latest/Command-Node/
#>
Node -Name 'Web-Server-01' -Attributes @{Label = 'Web-Server-01'; shape = 'rectangle'; fillColor = 'Green'; fontsize = 14 }
Node -Name 'App-Server-01' -Attributes @{Label = 'App-Server-01'; shape = 'rectangle'; fillColor = 'Blue'; fontsize = 14 }
Node -Name 'Db-Server-01' -Attributes @{Label = 'Db-Server-01'; shape = 'rectangle'; fillColor = 'Red'; fontsize = 14 }
<#
This section creates connections between the nodes in a hierarchical layout.
Add-NodeEdge cmdlet creates connections between nodes. (Part of AsBuiltReport.Diagram module)
https://github.com/AsBuiltReport/AsBuiltReport.Diagram
#>
Add-NodeEdge -From 'Web-Server-01' -To 'App-Server-01' -EdgeLabel 'gRPC' -EdgeColor 'black' -EdgeLabelFontSize 12 -EdgeLabelFontColor 'black' -EdgeLength 3 -EdgeThickness 3 -EdgeStyle 'dashed'
Add-NodeEdge -From 'App-Server-01' -To 'Db-Server-01' -EdgeLabel 'SQL' -EdgeColor 'black' -EdgeLabelFontSize 12 -EdgeLabelFontColor 'black' -EdgeLength 3 -EdgeThickness 3 -EdgeStyle 'dashed'
}
}
<#
This command generates the diagram using the New-AbrDiagram cmdlet (part of AsBuiltReport.Diagram).
-InputObject accepts the custom object created above.
-OutputFolderPath specifies where to save the generated diagram.
-Format sets the output format (png, jpg, svg, etc.).
-ImagesObj passes a hashtable of images for custom icons.
-MainDiagramLabel sets the diagram title.
-Filename specifies the output file name (without extension).
-LogoName selects which image from the hashtable to use as a logo in the diagram.
- If the specified logo image is not found, the diagram uses no_icon.png [?].
-Direction sets the diagram layout direction: left-to-right or top-to-bottom.
- The layout is set to top-to-bottom using the Graphviz attribute (TB).
-DraftMode, when set to $true, generates a draft version of the diagram for troubleshooting.
#>
New-AbrDiagram -InputObject $example4 -OutputFolderPath $OutputFolderPath -Format $Format -MainDiagramLabel $MainGraphLabel -Filename Example4 -LogoName 'Main_Logo' -Direction top-to-bottom -DraftMode:$DraftMode