Project

PSWriteOffice

PSWriteOffice is an open-source PowerShell and .NET project with packages, release history, and technical documentation.

Stars148
Forks14
Open issues0
PowerShell Gallery downloads158661
Releasev1.0.2
Language: C# Updated: 2026-07-05T16:05:48.0000000+00:00

Curated Examples

Create a Visio diagram

Use PSWriteOffice to create a Visio diagram with stencils, connectors, and exported previews.

This pattern is useful when a script needs to generate an editable .vsdx diagram and preview images for review.

It is adapted from Examples/Visio/Example-Visio-StencilFlow.ps1.

Example

Import-Module PSWriteOffice

$outputDirectory = Join-Path $PSScriptRoot 'Output'
New-Item -ItemType Directory -Path $outputDirectory -Force | Out-Null

$visioPath = Join-Path $outputDirectory 'OnboardingFlow.vsdx'
$svgPath = Join-Path $outputDirectory 'OnboardingFlow.svg'
$pngPath = Join-Path $outputDirectory 'OnboardingFlow.png'

New-OfficeVisio -Path $visioPath -Title 'Customer onboarding flow' -UseMastersByDefault -RequestRecalcOnOpen {
    Import-OfficeVisioStencil -BuiltIn Flowchart -Name Flow -Default | Out-Null

    VisioStencil -Catalog Flow -Stencil process -Key intake -Text 'Intake' -X 1.5 -Y 4
    VisioStencil -Catalog Flow -Stencil decision -Key review -Text 'Review?' -X 4 -Y 4
    VisioStencil -Catalog Flow -Stencil data -Key archive -Text 'Archive' -X 6.5 -Y 4
    VisioConnector -From intake -To review -Kind RightAngle -EndArrow Triangle -Label 'submit'
    VisioConnector -From review -To archive -Kind RightAngle -EndArrow Triangle -Label 'store'
}

Get-OfficeVisioInfo -Path $visioPath -AsText
ConvertTo-OfficeVisioSvg -Path $visioPath -OutputPath $svgPath
ConvertTo-OfficeVisioPng -Path $visioPath -OutputPath $pngPath

What this demonstrates

  • creating editable Visio diagrams without automating desktop Visio
  • using built-in stencils and connectors
  • exporting SVG and PNG previews from the same .vsdx

Source