# Automate Visio Diagrams

Create, 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](https://github.com/EvotecIT/OfficeIMO/tree/105ae88c45f6be3bb2020384e25ffe61d990451b/PowerShell/PSWriteOffice/Examples/Visio) and search the [command reference](/api/powershell/) for `OfficeVisio`.

<!-- PowerForge markdown source sha256:3FF8A7C9F83176DC6E61F9AB4E401D9975F656208F0410AB979F5334C71FFFF6; title=True -->

<!-- PowerForge markdown artifact sha256:9EAB744F7D6101489CCDE5936DFEE9EB1FD7A124DE58675F0937B5FE4A9F24C1 -->
