-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExample03.ps1
More file actions
71 lines (56 loc) · 3.47 KB
/
Example03.ps1
File metadata and controls
71 lines (56 loc) · 3.47 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
# ** This time we will extend the edges size using the Add-NodeEdge EdgeLength attribute. **
<#
Simple example of how to create a 3 tier web application diagram using the AsBuiltReport.Diagram. Without using any object icons.
#>
[CmdletBinding()]
param (
[System.IO.FileInfo] $Path = '~\Desktop\',
[array] $Format = @('png'),
[bool] $DraftMode = $false
)
<#
From Powershell v3 onwards, the module should not need to be explicitly imported. It is included
here to avoid any ambiguity.
#>
# Import-Module AsBuiltReport.Diagram -Force -Verbose:$false
<#
As the output of the diagram is a file, we need to specify the output folder path. In this example, $OutputFolderPath
#>
$OutputFolderPath = Resolve-Path $Path
<#
The $MainGraphLabel variable is used to set the main title of the diagram.
#>
$MainGraphLabel = 'Web Application Diagram'
$example3 = & {
<#
This creates a 3 server diagram with custom node labels and shapes (No Object icons).
The Node statements create the nodes in the diagram. (Node is a reserved word in 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 herarchical layout.
The Add-NodeEdge cmdlet creates connections between the nodes. (Part of AsBuiltReport.Diagram module)
https://github.com/AsBuiltReport/AsBuiltReport.Diagram
** The EdgeLength attribute is used to increase the minimum length of the edge lines. **
#>
Add-NodeEdge -From 'Web-Server-01' -To 'App-Server-01' -EdgeLabel 'gRPC' -EdgeColor 'black' -EdgeLabelFontSize 12 -EdgeLabelFontColor 'black' -EdgeLength 3
Add-NodeEdge -From 'App-Server-01' -To 'Db-Server-01' -EdgeLabel 'SQL' -EdgeColor 'black' -EdgeLabelFontSize 12 -EdgeLabelFontColor 'black' -EdgeLength 3
}
<#
This command generates the diagram using the New-AbrDiagram cmdlet (Part of AsBuiltReport.Diagram).
The -InputObject parameter accepts the custom object created above.
The -OutputFolderPath parameter specifies where to save the generated diagram.
The -Format parameter specifies the output format (png, jpg, svg, etc.).
The -ImagesObj parameter passes the hashtable of images for custom icons.
The -MainDiagramLabel parameter sets the title of the diagram.
The -Filename parameter specifies the name of the output file (without extension).
The -LogoName parameter specifies which image from the hashtable to use as a logo in the diagram.
If the specified logo image is not found in the hashtable, the diagram will be generated using a no_icon.png [?].
The -Direction parameter sets the layout direction of the diagram. Options are: left-to-right, top-to-bottom.
The layout is set to top-to-bottom (Top to Bottom) using the Graph attribute.
The -DraftMode parameter, when set to $true, generates a draft version of the diagram for troubleshooting.
#>
New-AbrDiagram -InputObject $example3 -OutputFolderPath $OutputFolderPath -Format $Format -MainDiagramLabel $MainGraphLabel -Filename Example3 -LogoName 'Main_Logo' -Direction top-to-bottom -DraftMode:$DraftMode