Merge-OfficeDocument
Combines documents of the same native format in input order.
Syntax
Merge-OfficeDocument
[-NoClobber]
[-Options <Object[]>]
[-OutputPath] <String>
[-PassThru]
[-Password <SecureString[]>]
[-Path] <String[]>
[-Show]
[<CommonParameters>]#PathMerge-OfficeDocument
[-Document] <IDisposable>
[-NoClobber]
[-Options <Object[]>]
[[-OutputPath] <String>]
[-PassThru]
[-Password <SecureString[]>]
[-Path] <String[]>
[<CommonParameters>]#DocumentMerge-OfficeDocument
-LiteralPath <String[]>
[-NoClobber]
[-Options <Object[]>]
[-OutputPath] <String>
[-PassThru]
[-Password <SecureString[]>]
[-Show]
[<CommonParameters>]#LiteralPathDescription
Supports PDF and Open XML Word and Excel files. Binary projection and conversion are not performed. Word and Excel live documents can receive appended files and remain caller-owned. PDF merging creates a new document, so live PDF targets are not supported. PassThru returns a saved FileInfo for file input or the live document for Document input. Native merge options determine which content is imported.
Examples
Combine PDFs in the specified order.
Merge-OfficeDocument -Path ./agenda.pdf, ./minutes.pdf -OutputPath ./board-pack.pdf -PassThruCombine Word files in pipeline order.
Get-ChildItem ./weekly -Filter *.docx | Sort-Object Name | Merge-OfficeDocument -OutputPath ./monthly.docxAppend files to a caller-owned proposal.
Merge-OfficeDocument -Document $proposal -Path ./scope.docx, ./pricing.docx -OutputPath ./proposal.docxParameters
- -NoClobber SwitchParameter
- Refuse to replace an existing destination; requires OutputPath.
- -Options Object[]
- Native merge settings, New-OfficeExcelMergeOptions results, or property hashtables for the selected format.
- -OutputPath String
- Destination with the same extension as every input; optional for a live document.
- -PassThru SwitchParameter
- Emit the saved FileInfo, or the caller-owned live document for Document input.
- -Password SecureString[]
- One source password reused for all files, or one password per resolved file in order; use $null for an unencrypted file in a per-file list.
- -Path String[]
- Files in merge order, or files appended to Document; wildcard matches retain provider order.
- -Show SwitchParameter
- Open the saved result through the shell after successful publication.
- -Document IDisposable
- A single editable Word or Excel document to append to; ownership stays with the caller.
- -LiteralPath String[]
- Literal files in merge order, including FileInfo.FullName and provider PSPath properties.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.