Automate Visio Diagrams
Edit on GitHubCreate, inspect, arrange, stencil, and export VSDX diagrams from PowerShell. Includes PowerShell examples, validation notes, and cmdlet links.
The Visio family exports 20 commands for VSDX authoring and inspection. Build pages from rectangles, ellipses, diamonds, containers, text boxes, connectors, and stencil shapes; arrange the result; save VSDX; and export SVG or PNG review artifacts.
Create with primitives or stencils
Use New-OfficeVisio and Add-OfficeVisioPage to start a diagram. Primitive commands are useful for lightweight flowcharts and architecture maps. For recognizable product and infrastructure shapes, load a built-in or imported catalog and use Add-OfficeVisioStencilShape.
Stencil commands can discover catalogs, find shapes, import packages, and export preview galleries. That separates shape selection from document placement and makes diagram scripts repeatable across environments.
Connect and arrange
Add-OfficeVisioConnector establishes graph relationships. Use layout and arrangement commands after content is complete, then apply targeted shape-layout updates only when the output needs manual refinement.
Inspect and review
Open-OfficeVisio returns the editable document. Get-OfficeDocumentInfo -Detailed returns a detached diagram snapshot in Details; use .Details.ToText() for its text report. Export-OfficeDocumentImage writes portable SVG or PNG review output from the editable VSDX source. Use -Page 1 -OutputPath ./diagram.svg, or -OutputDirectory ./pages -Format Png for every page. ConvertTo-OfficeDocumentImage returns the same native image results without writing files.
See the Visio examples and search the command reference for OfficeVisio.