Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

PowerShell · PSWriteOffice module

Office documents, straight from the pipeline.

Create, read, convert and check Word, Excel, PowerPoint, PDF, Visio, Project and more from PowerShell. Commands take and return objects, so reports fit into scheduled jobs, CI runners and Linux containers without Office.

InstallInstall-Module PSWriteOffice -Scope CurrentUser
  • No Office required
  • Objects in, documents out
  • MIT licensed

PowerShell Gallery · PowerShell 7.4+ on Windows, Linux and macOS · Windows PowerShell 5.1

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

# 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
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 · Read the walkthrough
commands
513
command families
25
PowerShell editions
5.1 · 7.4+
operating systems
3
Office installs needed
0

Explore the commands by document family

Every family links to its guide and to the generated command reference. Counts come from the module manifest of this release.

Excel 103 commands

Build, read, convert, validate, repair, compare, and publish XLS and XLSX workbook workflows.

  • New-OfficeExcel
  • Add-OfficeExcelTable
  • Add-OfficeExcelPivotTable
  • Test-OfficeDocument
  • Convert-OfficeDocument

Examples/Excel/Example-ExcelImportExport.ps1

$rows |
    Export-OfficeExcel -Path .\Revenue.xlsx -Sheet 'Revenue' -TableName 'Revenue' -Title 'Regional Revenue'

Import-OfficeExcel -Path .\Revenue.xlsx -Sheet 'Revenue' -Range 'A2:C5' |
    Format-Table -AutoSize

Word 81 commands

Create, inspect, update, review, merge, protect, and convert DOC and DOCX documents.

  • New-OfficeWord
  • Add-OfficeWordTable
  • Get-OfficeWordReview
  • Invoke-OfficeWordMailMerge
  • Convert-OfficeDocument

Examples/Word/Example-WordBasic.ps1

New-OfficeWord -Path .\Revenue.docx {
    Add-OfficeWordSection {
        Add-OfficeWordParagraph -Text 'Executive Summary' -Style Heading1
        Add-OfficeWordTable -InputObject $data -Style 'GridTable1LightAccent2' {
            Add-OfficeWordTableCondition -FilterScript { $_.Revenue -gt 100000 } -BackgroundColor '#e6fffb'
        }
    }
}

PDF 80 commands

Author, inspect, transform, sign, annotate, extract, preflight, and combine PDF files.

  • New-OfficePdf
  • Merge-OfficeDocument
  • Test-OfficeDocument
  • Set-OfficePdfSignature

Examples/Pdf/Example-PdfOperations.ps1

Merge-OfficeDocument -Path $first, $second -OutputPath $joined
Split-OfficeDocument -Path $joined -OutputDirectory $splitDirectory -Prefix 'part'
Add-OfficePdfStamp -Path $joined -OutputPath $stamped -Text 'REVIEWED' -Page '1'
Convert-OfficeDocument -To Markdown -Path $stamped -AsString

PowerPoint 53 commands

Compose, inspect, update, import, theme, and render repeatable presentation decks.

  • New-OfficePowerPoint
  • Add-OfficePowerPointSlide
  • Add-OfficePowerPointChart
  • Get-OfficePowerPointSlide

Markdown 33 commands

Compose typed Markdown, parse documents, and convert between Markdown and HTML or Word.

  • New-OfficeMarkdown
  • Add-OfficeMarkdownTable
  • Convert-OfficeDocument
  • Read-OfficeDocument

Visio 20 commands

Create, inspect, arrange, and export VSDX diagrams with built-in and imported stencils.

  • New-OfficeVisio
  • Add-OfficeVisioStencilShape
  • Get-OfficeDocumentInfo
  • Export-OfficeDocumentImage

Project 20 commands

Create schedules, inspect tasks and resources, exchange mapped tables, and save qualified native or XML projects.

  • New-OfficeProject
  • Invoke-OfficeProjectSchedule
  • Save-OfficeProject
  • Import-OfficeProjectTable

TOML 12 commands

Edit TOML files without losing comments or layout, and read and write TOML configuration and lock files as PowerShell objects.

  • Open-OfficeToml
  • Set-OfficeTomlNode
  • Import-OfficeToml
  • Export-OfficeToml

YAML 12 commands

Edit YAML files without losing comments or layout, merge overlays, and convert between YAML and objects.

  • Open-OfficeYaml
  • Set-OfficeYamlNode
  • ConvertFrom-OfficeYaml
  • Test-OfficeYaml

Examples/Yaml/Example-YamlEditMergeConvert.ps1

Open-OfficeYaml -Path $values {
    Set-OfficeYamlNode -Select 'image.tag' -Value '1.26'
    Set-OfficeYamlNode -Select 'resources.limits' -Value ([ordered]@{ cpu = '500m'; memory = '256Mi' })
}

OpenDocument 11 commands

Compose, read, convert, and save ODT, ODS, and ODP workflows.

  • New-OfficeOpenDocument
  • Add-OfficeOpenDocumentParagraph
  • Set-OfficeOpenDocumentCell
  • Save-OfficeOpenDocument

Email 9 commands

Read and write messages and mailbox artifacts through the managed OfficeIMO.Email engine.

  • Open-OfficeEmail
  • Open-OfficeEmailMailbox
  • Save-OfficeEmail
  • Save-OfficeEmailMailbox

Reader, extraction, and OCR 9 commands

Detect formats and extract normalized documents, chunks, tables, visuals, assets, OCR text, and ingest results.

  • New-OfficeDocumentReader
  • Read-OfficeDocument
  • Export-OfficeDocumentAsset
  • Search-OfficeDocument

Examples/Reader/Recipe-Reader-SearchFolder.ps1

Search-OfficeDocument -Path '.\Documents' -Pattern 'Retention' -Recurse -MaximumResults 0 |
    Select-Object DocumentType, Path, Match

Access 9 commands

Read native database schemas and rows, and create qualified table databases without ACE or COM.

  • New-OfficeAccess
  • Get-OfficeAccessRow
  • Add-OfficeAccessRow
  • Save-OfficeAccess

RTF 8 commands

Create, open, edit, inspect, and bridge Rich Text Format documents.

  • New-OfficeRtf
  • Open-OfficeRtf
  • Update-OfficeRtfText
  • Convert-OfficeDocument

EPUB 8 commands

Read, create, and save EPUB publications from chapters, resources, and metadata.

  • New-OfficeEpub
  • Add-OfficeEpubChapter
  • Get-OfficeEpubChapter
  • Save-OfficeEpub

Confluence Cloud 7 commands

Plan and publish pages, preserve managed sections, and transfer attachments through OfficeIMO.Confluence.

  • New-OfficeConfluenceSession
  • Publish-OfficeConfluencePage
  • Set-OfficeConfluenceManagedSection
  • Send-OfficeConfluenceAttachment

Before sharing 5 commands

Find and remove comments, authors, hidden content and image metadata, and check Content Credentials and AI labels before a file leaves your team.

  • Get-OfficeHiddenData
  • Remove-OfficeHiddenData
  • New-OfficeHiddenDataOptions
  • Get-OfficeDocumentProvenance

Examples/Workflows/Recipe-CleanBeforeSharing.ps1

Get-ChildItem -LiteralPath $outgoing -File | Get-OfficeHiddenData

Get-ChildItem -LiteralPath $outgoing -File |
    Remove-OfficeHiddenData -OutputDirectory $share

CSV 4 commands

Create, import, inspect, and export delimited data with typed options.

  • ConvertTo-OfficeCsv
  • Import-OfficeCsv
  • Export-OfficeCsv

LaTeX 3 commands

Read, create, update, and save bounded LaTeX interoperability workflows.

  • Open-OfficeLatex
  • New-OfficeLatexReadOptions
  • Convert-OfficeDocument
  • Save-OfficeLatex

AsciiDoc 3 commands

Read, create, update, and save bounded AsciiDoc workflows.

  • Open-OfficeAsciiDoc
  • New-OfficeAsciiDocReadOptions
  • Convert-OfficeDocument
  • Save-OfficeAsciiDoc

Start from a real job

Browse the recipe gallery

Quick start

Install the module, then turn the same rows into a Word report, an Excel table, a PowerPoint deck, and a PDF:

Install-Module PSWriteOffice

$regions = @(
    [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 }
)

New-OfficeWord -Path .\Report.docx {
    Add-OfficeWordSection {
        Add-OfficeWordParagraph -Style Heading1 -Text 'Monthly report'
        Add-OfficeWordParagraph -Text "Generated on $(Get-Date -Format 'MMMM yyyy')"
        Add-OfficeWordTable -InputObject $regions -Style GridTable4Accent1
    }
}

New-OfficeExcel -Path .\Revenue.xlsx {
    Add-OfficeExcelSheet -Name Revenue {
        Add-OfficeExcelTable -InputObject $regions -Name Revenue
    }
}

New-OfficePowerPoint -Path .\Status.pptx {
    PowerPointSlide -Title 'Monthly status' {
        PowerPointList 'Three of four regions above target', 'East is 3% short'
    }
    PowerPointSlide -Title 'Revenue by region' {
        PowerPointTable -InputObject $regions
    }
}

Convert-OfficeDocument -Path .\Report.docx -OutputPath .\Report.pdf

The DSL cookbook builds on the same pattern for each format, and Get-Help <command> -Full shows every parameter.

Where it runs

PlatformPowerShellSupported
Windows5.1Yes
Windows7.4+Yes
Linux7.4+Yes
macOS7.4+Yes

Built for scripts that run unattended

Objects in, objects out
Pipe objects into tables, charts and reports. Readers return objects you can filter with Where-Object and export again.
Both PowerShell editions
Windows PowerShell 5.1 on Windows and PowerShell 7.4+ on Windows, Linux and macOS, from one module.
No Office, no COM
Runs in scheduled tasks, CI runners and containers. Nothing opens a desktop application.
Readable DSL
Script blocks with short aliases such as WordParagraph and ExcelSheet for interactive work, full Add-Office* names for shared scripts.
Generated help
Every command ships with help and examples, and the online reference is generated from the same source.
Moving from older modules
Migration guides cover PSWriteWord, PSWriteExcel and PSWritePDF, and compare ImportExcel.

Measured, not claimed

PSWriteOffice runs the same OfficeIMO engines measured on the benchmark pages.

PowerShell benchmark guide

Read the guides Install, Word, Excel, PowerPoint, PDF, Visio, Reader and migration. Command reference Every command with parameters, examples and aliases.

Installation channels

Available

PowerShell Gallery

Install-Module PSWriteOffice, or Install-PSResource PSWriteOffice with PSResourceGet

Open the Gallery →

Available

Offline servers

Save-Module PSWriteOffice on a connected machine, then copy the folder into a PSModulePath location

Installation guide →

Available

Source

The module source, examples and tests live in the OfficeIMO repository

Open the source →

Same engine, other surfaces

Use OfficeIMO another way

Example source