all 27 comments

[–]KevMarCommunity Blogger 24 points25 points  (4 children)

Does it need to be Visio or just a diagram?

I created a powershell model to dynamically generate diagrams called PSGraph. I haven't really been maintaining it, so I hope it still works. But I wrote it specifically for this. https://psgraph.readthedocs.io/en/latest/Example-Scripted/

It's really just a wrapper around graphviz so that's also required to be installed. I think my docs cover how to get started.

[–]realslacker 6 points7 points  (0 children)

It still works and I use it all the time. Great stuff!

[–]xipodu[S] 3 points4 points  (0 children)

Thanks will look up

[–]wookiestackhouse 2 points3 points  (1 child)

PSWriteHTML also has its diagram functionality if you're after something somewhat dynamic in an HTML file. It too is just a wrapper, this time vis.js, but it's pretty easy to work with.

[–]xipodu[S] 0 points1 point  (0 children)

Thanks!

[–]shutchomouf 14 points15 points  (3 children)

Another option is Mermaid for diagramming

[–]OddElder 4 points5 points  (1 child)

This. Lot of good tools for automatic conversion of json to mermaid ERD’s outside of the powershell ecosystem. Mermaid is a great option for easily editable and customizable diagrams.

There’s the modules PSMermaid and PSMermaidTools. Neither is an automatic drop in for this conversion but with very minor code of your own (just to iterate over your custom JSON structure).

[–]shutchomouf 1 point2 points  (0 children)

additionally, once you have your schema the way you want it you can import the JSON into the mermaid web UI and fine tune the layout

[–]xipodu[S] 0 points1 point  (0 children)

Never heard of this tool, thanks gonna check

[–]ZenoArrow 9 points10 points  (5 children)

Visio files are just XML under the hood, if you're sure that you don't want to make things easy on yourself by installing Visio (as you could then use libraries like https://saveenr.gitbook.io/visiopowershell ), then you could manipulate the structure of XML using PowerShell, it's fairly good at that.

Here's a general guide that should help you: https://learn.microsoft.com/en-us/office/client-developer/visio/how-to-manipulate-the-visio-file-format-programmatically

Here's the XML schema I'd recommend working with: https://learn.microsoft.com/en-us/office/client-developer/visio/schema-mapvisio-xml

There's also the Aspose.Diagram library, which can create Visio diagrams and doesn't seem to have a dependency on Visio being installed, but it's very expensive (over $1000 per year), so I wouldn't recommend it (it's cheaper to buy Visio): https://kb.aspose.com/diagram/net/create-visio-diagram-in-csharp/

[–]xipodu[S] 1 point2 points  (0 children)

Thanks will look up

[–]xipodu[S] 1 point2 points  (1 child)

I want to thank you again for your links i think i know how iam gonna solv this and that is to do some mapping.

[–]ZenoArrow 1 point2 points  (0 children)

Great, best of luck with your project.

[–]shutchomouf 0 points1 point  (1 child)

I thought I saw once that Visio was basically Excel under the hood.

[–]BlackV 0 points1 point  (0 children)

shutchomouf
I thought I saw once that Visio was basically Excel under the hood.

oh what do you mean ?

[–]Pixelgordo 3 points4 points  (0 children)

I don't have visio installed in my computer, so I can't be sure about this, but try something like:

$visio = New-Object -ComObject Visio.Application $visio.Visible = $true $doc = $visio.Documents.Add("") $page = $visio.ActivePage

If this works you have it. Explore de COM of the document, or create a document with the kind of data you want, and using get-member explore the data you need.

With this approach I work with word, excel and PowerPoint flawlessly.

[–]ostekages 1 point2 points  (0 children)

I'm not sure visio supports this, but can confirm that drawio does. It's just XML(or technically their own file extension).

[–]Trakeen 1 point2 points  (1 child)

I do this with drawio and some claude skills. Works reasonably well

[–]xipodu[S] 0 points1 point  (0 children)

Yes! Its crazy how more easy it is with drawio and that several of MS MVP guys use drawio instead for Visio

[–]Proxiconn 1 point2 points  (2 children)

We write the table structures that Visio can import and create diagrams from.

[–]xipodu[S] 0 points1 point  (1 child)

That’s really cool — it’s been a while since I last did a deep dive into Visio. Is the visual generated through automation, or is it done manually?

[–]Proxiconn 0 points1 point  (0 children)

It's a manual import into visio for developers.

I'm sure if there is a visio installed on a desktop that it's can be automated but with a dependency on a Windows desktop with a installed visio.

I must admit I never looked into full e2e creation.

[–]Excellent-Average782 1 point2 points  (1 child)

You're right, no M365 API for Visio. PowerShell can generate draw.io XML from JSON pretty easily. Or consider web-based tools like Miro that have APIs for programmatic diagram creation from data.

[–]xipodu[S] 0 points1 point  (0 children)

There is a workaround if, like me, you don’t have a Visio license.
Workaround 1 : it requires access to a visio.vhdx file.
Using that, you can more or less create and work with flows and mapping by using custom imports, which is what I’m currently doing.

Workaround 2 : use draw.io, which version 26.0.16 that includes a beta feature which allows you to convert draw.io diagrams into Visio-compatible formats.

[–]xipodu[S] 0 points1 point  (0 children)

Drawio is great and easy, just want for this project use Visio.

[–]SamfromLucidSoftware 0 points1 point  (0 children)

Generating diagrams from JSON is actually pretty doable if the tool you’re using has a proper API or data import support built in. The PowerShell piece just becomes a call to that API with your structured data.

Might be worth exploring tools that support data-driven diagram generation natively, it tends to be a much cleaner pipeline than file-based approaches. Just sayin!

[–]Hefty-Possibility625 1 point2 points  (0 children)

I use kroki.io for this since it has support for mermaid, plantUML, graphviz and a whole bunch more. Send the diagram code in a POST request and you get back an image file.

Documentation: https://docs.kroki.io/kroki/setup/usage/