Version: 0.Such.Alpha.1
Some simple PowerShell functions to make creating and editing NetJson files easier.
Right now only the NetGraph and NetCollection objects are supported, I'll add more if/when I can use them.
The New functions all return custom objects that serialize to/from 'json' with valid NetJson schema.
I wanted to make cool network graphs with netjsongraph.js like this:
Create an empty NetGraph.
New-NetGraph -Static -label "My Network"
Create an empty NetGraphNode.
New-NetGraphNode -ID 'pswitch' -Label "Primary Switch"
Attach Nodes to a Graph:
$graph = New-NetGraph -Static -label "My Network"
$graph.nodes += New-NetGraphNode -ID 'router1' -Label "Router"
$graph.nodes += New-NetGraphNode -ID 'pswitch' -Label "Primary Switch"
Add links to the graph:
$graph.links += New-NetGraphLink -Source 'router1' -Target 'pswitch' -Cost 0
Export the Graph using the standard ConvertTo-Json
cmdlet.
The only catch is you need to specify a depth of 5, as the the default depth will populate the properties objects with the type, not the actual object.
$graph | ConvertTo-Json -Depth 5 | Out-File -FilePath "netgraph.json"
- help info on the functions.
- cmdlet binding and pipeline support.
- maybe some
get
oradd
helpers, if needed. - more NetJson types?
- maybe some pester tests?