Skip to main content
OfficeIMO Docs Search documentation/

PowerShell Document Recipes

Edit on GitHub

Practical PSWriteOffice patterns for reports, presentations, PDF, CSV, Markdown, RTF, and document extraction.

PSWriteOffice exposes the OfficeIMO engines as pipeline-friendly commands and authoring blocks. These recipes are starting points for scheduled jobs, CI artifacts, admin tools, and repeatable reporting.

Turn objects into a finished Excel workbook

$rows = Get-Service | Select-Object Name, Status, StartType

$rows | Export-OfficeExcel `
    -Path '.\Service-Inventory.xlsx' `
    -WorksheetName 'Services' `
    -TableName 'ServiceInventory' `
    -BoldTopRow `
    -FreezeTopRow `
    -AutoFit

Use database reporting when the source is DbaClientX, and the operational dashboard example when the workbook needs a more designed summary.

Create Word and PDF side by side

New-OfficeWord -Path '.\Change-Report.docx' -PdfPath '.\Change-Report.pdf' {
    Add-OfficeWordSection {
        Add-OfficeWordParagraph -Style Heading1 -Text 'Change report'
        Add-OfficeWordParagraph -Text "Generated $(Get-Date -Format u)"
        Add-OfficeWordTable -InputObject $changes -Style GridTable4Accent1
    }
}

The PDF sidecar example also shows Markdown-to-PDF output. Keep the editable source and delivery PDF together when both are part of the workflow contract.

Build a PDF report directly

Use New-OfficePdf when the PDF is the primary artifact rather than a converted Office document:

New-OfficePdf -Path '.\Deployment-Evidence.pdf' {
    Add-OfficePdfHeading -Text 'Deployment evidence' -Level 1
    Add-OfficePdfParagraph -Text 'Generated from the validated deployment run.'
}

Continue with the PDF report DSL example for the currently supported authoring components.

Build repository-friendly Markdown

New-OfficeMarkdown -Path '.\release-notes.md' {
    Add-OfficeMarkdownHeading -Text 'Release notes' -Level 1
    Add-OfficeMarkdownParagraph -Text 'Generated from the release pipeline.'
}

The Markdown examples cover the fluent block, tables, callouts, details, front matter, and conversion-oriented patterns.

Export delimited data with an explicit contract

$rows | Export-OfficeCsv -Path '.\inventory.csv' -Delimiter ';'
$table = Import-OfficeCsv -Path '.\inventory.csv' -AsDataTable -InferSchema

Choose the delimiter, culture, compression, quote policy, headers, schema, and error behavior deliberately. Use the CSV examples and performance evidence for large or database-shaped transfers.

Extract across document formats

$detection = Get-OfficeDocumentDetection -Path '.\incoming\proposal.docx'
$document = Get-OfficeDocument -Path '.\incoming\proposal.docx'
$chunks = Get-OfficeDocumentChunk -Path '.\incoming\proposal.docx'

Use the normalized Reader commands for indexing, migration, classification, search preparation, and bulk ingest. Use a native family when the script must modify Word, Excel, PowerPoint, PDF, Visio, RTF, or another format-specific model.

Create and review a presentation

Start with the PowerPoint service brief for a complete deck, or the PowerPoint examples for focused charts, layouts, themes, transitions, imported slides, and HTML review.

See the PSWriteOffice command families for the supported surface and release previews before relying on commands that are still waiting for package publication.