Project

PSWriteOffice

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

Stars144
Forks12
Open issues16
PowerShell Gallery downloads150904
Releasev0.2.0
Language: C# Updated: 2026-04-06T15:21:31.0000000+00:00

Curated Examples

Create a Word report

Use PSWriteOffice to generate a Word document with text, a list, and a table.

This pattern is useful when an operational script needs to leave behind a readable Word document.

It is adapted from Examples/Word/Example-WordBasic.ps1.

Example

Import-Module PSWriteOffice

$outputPath = Join-Path $PSScriptRoot 'Output\RevenueSnapshot.docx'
New-Item -ItemType Directory -Path (Split-Path $outputPath) -Force | Out-Null

$data = @(
    [PSCustomObject]@{ Region = 'North America'; Revenue = 125000; YoY = '12%' }
    [PSCustomObject]@{ Region = 'EMEA'; Revenue = 98000; YoY = '22%' }
    [PSCustomObject]@{ Region = 'APAC'; Revenue = 143000; YoY = '18%' }
)

New-OfficeWord -Path $outputPath {
    Add-OfficeWordSection {
        Add-OfficeWordParagraph -Text 'Executive Summary' -Style Heading1
        Add-OfficeWordParagraph -Text 'Revenue accelerated in all regions.'
        Add-OfficeWordList -Style Numbered {
            Add-OfficeWordListItem -Text 'North America +12% YoY'
            Add-OfficeWordListItem -Text 'EMEA +22% YoY'
            Add-OfficeWordListItem -Text 'APAC +18% YoY'
        }
        Add-OfficeWordTable -InputObject $data -Style 'GridTable1LightAccent2'
    }
}

What this demonstrates

  • creating a Word document from a PowerShell script
  • mixing paragraphs, lists, and structured data
  • writing output to a predictable script-local folder

Source