Example 1
This is a simple example demonstrating how to create a 3-tier web application diagram using the PSGraph module, without using any object icons.
[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 block creates a diagram with three servers, each represented by a custom node label and shape (without object icons).
Finally, call the New-Diagrammer cmdlet with the specified parameters.
New-Diagrammer -InputObject $example1 -OutputFolderPath $OutputFolderPath -Format $Format -MainDiagramLabel $MainGraphLabel -Filename Example1 -LogoName "Main_Logo" -DraftMode:$DraftMode
The parameters used in the New-Diagrammer cmdlet are explained below:
-InputObject: Accepts the custom object defined 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's title.
-Filename: Specifies the output file name (without extension).
-LogoName: Selects an image from the hashtable to use as the diagram logo.
- If the specified logo image is not found, a default no_icon.png is used.
-DraftMode: If set to $true, generates a draft version of the diagram for troubleshooting.
When you run the script, it generates a PNG file named Example1.png in the specified output folder.
Resulting diagram: