I'm looking for advice on how to generate a Visio diagram using PowerShell with data sourced from a JSON file. Most of the examples I've come across require Visio to be installed on a local machine and use file-based methods. I'm under the impression that Microsoft 365 doesn't provide an open API for this purpose, but I could be mistaken. If it helps, I'm open to the idea of first converting my data into a drawio file before turning it into a Visio diagram.
3 Answers
Have you considered whether you really need Visio specifically, or if any diagram will work? I created a PowerShell tool called PSGraph that lets you dynamically generate diagrams, and it’s pretty straightforward! It wraps around graphviz, so you'd need that installed as well. I’ve written documentation to help you get started, and it should still be operational! Check it out here: https://psgraph.readthedocs.io/en/latest/Example-Scripted/
Thanks for the tip, I’ll definitely check it out!
PSWriteHTML also provides some cool diagram features if you're into generating dynamic content within HTML files. It's user-friendly too!
If you don't want to deal with installing Visio, but still want to create Visio files, remember that Visio files are fundamentally XML. You can manipulate this XML directly with PowerShell. There are helpful resources out there to guide you through the process. Check out this general guide: https://learn.microsoft.com/en-us/office/client-developer/visio/how-to-manipulate-the-visio-file-format-programmatically. You might also look into the XML schema here: https://learn.microsoft.com/en-us/office/client-developer/visio/schema-mapvisio-xml.
Thanks for the links! I’ll give it a shot.
I’m not entirely sure if Visio supports this kind of functionality, but I do know that drawio does a good job with XML diagrams. Their file extension is unique, but it might serve your needs!

It still works like a charm for me. Super useful tool!