Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

PowerShell document automation

PSWriteOffice

Automate Word, Excel, PowerPoint, PDF, Reader, Visio, Markdown, CSV, RTF, OpenDocument, email, AsciiDoc, and LaTeX workflows from PowerShell.

MIT licensed No Office required PowerShell 5.1 and 7+
Install Install-Module PSWriteOffice
Independent render of the generated patch compliance report: a headline compliance figure, a per-site table with watch rows highlighted, a bar chart and numbered next steps
Patch compliance report from PowerShell

The downloadable DOCX and PDF come from the PowerShell script shown beside them, run against the PSWriteOffice version the command catalog documents. The preview is an independent Poppler render of that PDF.

Download DOCX · View source · Explore the example
PowerShell · excerpt from the example; follow the walkthrough for the complete code
# Sample inventory; replace it with your own query. Any objects with properties work.
$sites = @(
    [pscustomobject]@{ Site = 'Warsaw';    Servers = 84; Patched = 80; Pending = 4; Status = 'On target' }
    [pscustomobject]@{ Site = 'Frankfurt'; Servers = 66; Patched = 58; Pending = 8; Status = 'Watch' }
    [pscustomobject]@{ Site = 'Dublin';    Servers = 52; Patched = 50; Pending = 2; Status = 'On target' }
    [pscustomobject]@{ Site = 'Chicago';   Servers = 71; Patched = 69; Pending = 2; Status = 'On target' }
    [pscustomobject]@{ Site = 'Singapore'; Servers = 38; Patched = 33; Pending = 5; Status = 'Watch' }
)
$servers = ($sites | Measure-Object Servers -Sum).Sum
$patched = ($sites | Measure-Object Patched -Sum).Sum
$rows = $sites | Select-Object Site, Servers, Patched, Pending,
    @{ Name = 'Compliance'; Expression = { "$([math]::Round(100 * $_.Patched / $_.Servers, 1))%" } }, Status

New-OfficeWord -Path $docxPath {
    WordHeader -Type Default { WordParagraph -Text 'Contoso IT operations - week 41' }
    WordFooter -Type Default { WordPageNumber -IncludeTotal }

    WordParagraph {
        Set-OfficeWordParagraph -SpacingAfter 14 -KeepWithNext:$true
        WordText 'Patch compliance report' -Bold -Size 26 -Color '17365D'
    }
    WordParagraph {
        WordText "$([math]::Round(100 * $patched / $servers, 1))%" -Bold -Size 20 -Color '166534'
        WordText "  of $servers production servers are patched, $($servers - $patched) are pending." -Size 12
    }

    WordParagraph {
        Set-OfficeWordParagraph -Style Heading1 -SpacingBefore 16 -SpacingAfter 8 -KeepWithNext:$true
        WordText 'Compliance by site' -Bold -Size 15 -Color '17365D'
    }
    $table = WordTable -InputObject $rows -Style GridTable4Accent1 -Layout AutoFitToWindow -PassThru {
        WordTableCondition -FilterScript { $_.Status -eq 'Watch' } -BackgroundColor '#fff4d6'
    }
    $table | Get-OfficeWordTableCell | ForEach-Object {
        $_.MarginTop = [OfficeIMO.OfficeLength]::Centimeters(0.12)
        $_.MarginBottom = [OfficeIMO.OfficeLength]::Centimeters(0.12)
        $_.MarginLeft = [OfficeIMO.OfficeLength]::Centimeters(0.16)
        $_.MarginRight = [OfficeIMO.OfficeLength]::Centimeters(0.16)
    }
    WordParagraph {
        Set-OfficeWordParagraph -SpacingBefore 14 -SpacingAfter 12
        WordChart -Type Bar -InputObject $rows -Category Site -Value Patched, Pending `
            -Title 'Patched and pending by site' -Legend -FitToPageWidth -WidthFraction 1 -Height '260px'
    }

    WordParagraph {
        Set-OfficeWordParagraph -Style Heading1 -SpacingBefore 10 -SpacingAfter 8 -KeepWithNext:$true
        WordText 'Next steps' -Bold -Size 15 -Color '17365D'
    }
    WordList -Style Numbered {
        WordListItem -Text 'Frankfurt: patch the eight pending servers in the Thursday window.'
        WordListItem -Text 'Singapore: confirm the maintenance slot with the regional owner.'
    }
}
Convert-OfficeDocument -LiteralPath $docxPath -OutputPath $pdfPath -Route docx-pdf

Why PSWriteOffice?

PSWriteOffice brings the OfficeIMO document stack to PowerShell. The command surface shown here is generated from the current module manifest used for this release. Create, inspect, update, review, convert, secure, and deliver documents from scripts and automation jobs without maintaining a separate document engine.

Features

  • Manifest-derived command catalog — cmdlets, aliases, and families are counted from the current module manifest
  • DSL aliases — intuitive shorthand like WordParagraph, ExcelSheet, and PptSlide for concise scripts
  • Broad document platform — Word, Excel, PowerPoint, PDF, Reader, Visio, Markdown, CSV, RTF, OpenDocument, email, AsciiDoc, LaTeX, and HTML asset workflows
  • Cross-platform — PowerShell 7.4 or newer runs on Windows, Linux, and macOS
  • Windows PowerShell — supports Windows PowerShell 5.1 on Windows; modern batch PDF export requires PowerShell 7.4 or newer

Command families

The current module exports 482 cmdlets and 176 aliases across 22 documentation families. Cross-format commands have one documentation owner, so the family totals match the manifest.

FamilyCmdletsTypical work
Project20Create schedules, inspect tasks and resources, exchange mapped tables, and save qualified native or XML projects.
Access9Read native database schemas and rows, and create qualified table databases without ACE or COM.
EPUB8Read, create, and save EPUB publications from chapters, resources, and metadata.
Document operations and capabilities11Inspect, compare, validate, repair, protect, combine, split, and convert documents through the shared native operations.
Word81Create, inspect, update, review, merge, protect, and convert DOC and DOCX documents.
Excel103Build, read, convert, validate, repair, compare, and publish XLS and XLSX workbook workflows.
PowerPoint53Compose, inspect, update, import, theme, and render repeatable presentation decks.
PDF77Author, inspect, transform, sign, annotate, extract, preflight, and combine PDF files.
Reader, extraction, and OCR11Detect formats and extract normalized documents, chunks, tables, visuals, assets, OCR text, and ingest results.
Archive migration and evidence5Inspect package safety and provenance, convert iWork and offline OneNote content, and retain fidelity evidence.
Google Workspace1Create an authenticated session for native Google Docs, Sheets, and Slides operations.
Confluence Cloud7Plan and publish pages, preserve managed sections, and transfer attachments through OfficeIMO.Confluence.
Visio20Create, inspect, arrange, and export VSDX diagrams with built-in and imported stencils.
Markdown33Compose typed Markdown, parse documents, and convert between Markdown and HTML or Word.
RTF8Create, open, edit, inspect, and bridge Rich Text Format documents.
CSV3Create, import, inspect, and export delimited data with typed options.
OpenDocument11Compose, read, convert, and save ODT, ODS, and ODP workflows.
Email9Read and write messages and mailbox artifacts through the managed OfficeIMO.Email engine.
AsciiDoc3Read, create, update, and save bounded AsciiDoc workflows.
LaTeX3Read, create, update, and save bounded LaTeX interoperability workflows.
HTML assets5Export images and review surfaces used by document-to-HTML workflows.
Cross-format visuals1Convert reusable visual artifacts for Word, Excel, PowerPoint, and PDF placement.

Browse the generated family guide or search the PowerShell API reference for parameter-level detail.

Start from a real workflow

JobWorking path
Review patch compliance and maintenance actionsPatch report walkthrough and native downloads
Reconcile budget, actual spending and forecastBudget review, workbook and CSV input
Review delivery milestones and overdue actionsProject review, milestone register and CSV input
Export SQL data to Excel and verify the round tripDbaClientX database reporting guide and the runnable Excel example
Move database data through CSVRunnable CSV round-trip example
Create an operational Excel dashboardExcel showcase example
Review quarterly support demand in PowerPointCSV-driven service brief with location totals, ticket comparisons and dated actions.
Browse copyable PowerShell patternsPSWriteOffice recipe gallery
Compare Excel and CSV performancePSWriteOffice benchmark guide
Evaluate mixed search, authenticated PDF, or Confluence publishingPSWriteOffice command families

Quick start

# Install the module
Install-Module PSWriteOffice -Force

# Create a Word document
New-OfficeWord -Path ".\Report.docx" {
    Add-OfficeWordSection {
        Add-OfficeWordParagraph -Style Heading1 -Text "Monthly Report"
        Add-OfficeWordParagraph -Text "Generated on $(Get-Date -Format 'MMMM yyyy')"

        $data = @(
            [pscustomobject]@{ Region = "North"; Revenue = 42000; Target = 40000 }
            [pscustomobject]@{ Region = "South"; Revenue = 38000; Target = 35000 }
            [pscustomobject]@{ Region = "East";  Revenue = 29000; Target = 30000 }
            [pscustomobject]@{ Region = "West";  Revenue = 51000; Target = 45000 }
        )

        Add-OfficeWordTable -InputObject $data -Style GridTable4Accent1
        Add-OfficeWordParagraph {
            Add-OfficeWordText -Text "All regions met or exceeded targets except East."
        }
    }
}

# Create an Excel workbook
New-OfficeExcel -Path ".\Metrics.xlsx" {
    Add-OfficeExcelSheet -Name "Summary" {
        Set-OfficeExcelCell -Address "A1" -Value "Metric"
        Set-OfficeExcelCell -Address "B1" -Value "Value"
        Set-OfficeExcelCell -Address "C1" -Value "Status"
        Set-OfficeExcelCell -Address "A2" -Value "Uptime"
        Set-OfficeExcelCell -Address "B2" -Value "99.97%"
        Set-OfficeExcelCell -Address "C2" -Value "OK"
        Set-OfficeExcelCell -Address "A3" -Value "Response Time"
        Set-OfficeExcelCell -Address "B3" -Value "42ms"
        Set-OfficeExcelCell -Address "C3" -Value "OK"
    }

    Add-OfficeExcelSheet -Name "Details" {
        Set-OfficeExcelCell -Address "A1" -Value "Timestamp"
        Set-OfficeExcelCell -Address "B1" -Value "Endpoint"
        Set-OfficeExcelCell -Address "C1" -Value "Latency"
        $rowIndex = 2
        1..10 | ForEach-Object {
            Set-OfficeExcelCell -Row $rowIndex -Column 1 -Value ((Get-Date).AddMinutes(-$_))
            Set-OfficeExcelCell -Row $rowIndex -Column 2 -Value "/api/data"
            Set-OfficeExcelCell -Row $rowIndex -Column 3 -Value (Get-Random -Minimum 20 -Maximum 80)
            $rowIndex++
        }
    }
}

# Create a PowerPoint presentation
$ppt = New-OfficePowerPoint -FilePath ".\Status.pptx"
$slide = Add-OfficePowerPointSlide -Presentation $ppt
Add-OfficePowerPointTextBox -Slide $slide -Text "Weekly Status" -X 80 -Y 60 -Width 520 -Height 50
Add-OfficePowerPointBullets -Slide $slide -Bullets @(
    "Shipped v3.2 to production",
    "Resolved 14 customer tickets",
    "Completed security audit"
) -X 80 -Y 150 -Width 520 -Height 220
$ppt | Save-OfficePowerPoint

Compatibility

PlatformPowerShell VersionSupported
Windows5.1Yes
Windows7+Yes
Linux7+Yes
macOS7+Yes

PSWriteOffice is available from the PowerShell Gallery and includes generated help for its cmdlet surface.

GuideDescription
PSWriteOffice overviewStart with installation, command families, and module scope.
PowerPoint cmdletsBuild generated decks with slides, bullets, tables, and images.
Markdown cmdletsGenerate Markdown reports and repository-friendly docs from scripts.
Database reportingConnect DbaClientX queries and bulk writes to Excel and CSV artifacts.
Performance evidenceReproduce the PowerForge-backed Excel and CSV comparisons.
OfficeIMO roadmapSee open cross-package work without mixing it into current command documentation.
PowerShell API referenceBrowse the full cmdlet surface with parameters and examples.
PackageDescription
OfficeIMO.Word.NET library powering Word document creation
OfficeIMO.Excel.NET library powering Excel workbook creation
OfficeIMO.PowerPoint.NET library powering PowerPoint presentation creation

Same engine, other surfaces

Use OfficeIMO another way

Next step

Turn the package into a working document.

Follow a focused guide and inspect the API reference for this package.

Example source