Public/New-Networkmap.ps1
<#
.SYNOPSIS Creates a draw.io compatible CSV file. .DESCRIPTION Creates a draw.io compatible CSV file that can be used to create a network map. The network map can be created with multiple layouts, organic is recommended for 'radial' layouts. Uses the file macaddress.io-db.csv to compare mac addresses and find the correct image. Also uses a guesstimate to check which device is what type. .PARAMETER Network CIDR notation of the network to scan. If no network is given it will scan all connected networks .EXAMPLE New-Networkmap -Network 192.168.15.1/24 -Layout organic -verbose .INPUTS System.String. You can pipe network values into this command .OUTPUTS CSV file #> function New-Networkmap { [CmdletBinding()] Param( [Parameter(ParameterSetName = 'Network', Mandatory = $false)] [Parameter(ValueFromPipelineByPropertyName = $true)] [String]$Network, [Parameter(ParameterSetName = 'Network', Mandatory = $false)] [Array]$SkipIPs, [Parameter(Mandatory = $true)] [ValidateSet('auto', 'none', 'verticaltree', 'horizontaltree', 'verticalflow', 'horizontalflow', 'organic', 'circle')]$Layout ) begin { write-host "Creating network diagram" } process { if (!$Network) { $NetScan = Get-Networkscan } else { $NetScan = Get-Networkscan -network $Network } if ($Netscan) { $CSV = @" ##Network Diagram generated by PsDrawIO # label: %hostname% # style: shape=%shape%;fillColor=%fill%;strokeColor=%stroke%;verticalLabelPosition=bottom;aspect=fixed; # namespace: csvimport- # connect: {"from":"refs", "to":"id", "invert":true, "style": \ # "curved=0;endArrow=none;endFill=0;dashed=1;strokeColor=#6c8ebf;"} # width: 40 # height: 40 # ignore: id,shape,fill,stroke,refs # nodespacing: 20 # levelspacing: 20 # edgespacing: 20 # layout: $Layout ## CSV data starts below this line "@ $Scan = $($netscan | ConvertTo-Csv -Delimiter ',' -NoTypeInformation) return $CSV, $SCAN } else { Write-Warning "Could not scan network." } } } |