# Search-OfficeDocument

Finds regular-expression or literal matches across supported files and folders.

Cmdlet 

**Module**

`PSWriteOffice`

**Inputs**

`OfficeIMO.Reader.OfficeDocumentReadResult` `System.String[]`

**Outputs**

`PSWriteOffice.Models.Reader.OfficeDocumentSearchMatch`

**Source**

[SearchOfficeDocumentCommand.cs:18](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Reader/SearchOfficeDocumentCommand.cs#L18) 

Finds regular-expression or literal matches across supported files and folders.

## Syntax

```
Search-OfficeDocument
[-CaseSensitive]
[-Extension <String[]>]
[-IncludePageLocations]
[-MaximumFiles <Int32>]
[-MaximumResults <Int32>]
[-MaximumStoreItems <Int32>]
[-Password <SecureString>]
[-Path] <String[]>
[-Pattern] <String[]>
[-Reader <OfficeDocumentReader>]
[-Recurse]
[-SimpleMatch]
[-ThrottleLimit <Int32>]
[-WholeWord]
[<CommonParameters>]
```

[#](#method-search-officedocument-switchparameter-string-switchparameter-int32-int32-int32-securestring-string-string-officedocumentreader-switchparameter-switchparameter-int32-switchparameter)

Parameter set: `Path`

```
Search-OfficeDocument
[-CaseSensitive]
[-InputObject] <OfficeDocumentReadResult>
[-MaximumResults <Int32>]
[-Pattern] <String[]>
[-SimpleMatch]
[-WholeWord]
[<CommonParameters>]
```

[#](#method-search-officedocument-switchparameter-officedocumentreadresult-int32-string-switchparameter-switchparameter)

Parameter set: `InputObject`

```
Search-OfficeDocument
[-CaseSensitive]
[-Extension <String[]>]
[-IncludePageLocations]
-LiteralPath <String[]>
[-MaximumFiles <Int32>]
[-MaximumResults <Int32>]
[-MaximumStoreItems <Int32>]
[-Password <SecureString>]
[-Pattern] <String[]>
[-Reader <OfficeDocumentReader>]
[-Recurse]
[-SimpleMatch]
[-ThrottleLimit <Int32>]
[-WholeWord]
[<CommonParameters>]
```

[#](#method-search-officedocument-switchparameter-string-switchparameter-string-int32-int32-int32-securestring-string-officedocumentreader-switchparameter-switchparameter-int32-switchparameter)

Parameter set: `LiteralPath`

## Guides & Samples

Authored walkthroughs and practical samples linked to this command.

- [Reader, Document Extraction, and OCR](/docs/pswriteoffice/reader/) Guide
  
  Detect formats and extract normalized documents, chunks, hierarchy, tables, visuals, assets, OCR text, and ingest results. Includes examples and cmdlet links.
- [Search Across Office and Document Files](/docs/pswriteoffice/reader-search-corpus/) Guide
  
  Search a bounded folder or explicit file set across Word, Excel, PowerPoint, PDF, Markdown, email, and other Reader-supported formats.

## Examples

### Find invoice identifiers in a mixed folder.

```powershell
Search-OfficeDocument ./Reports -Recurse -Pattern 'INV-\d+'
```

### Find literal text in an already read document.

```powershell
Read-OfficeDocument ./Report.docx | Search-OfficeDocument -Pattern 'retention period' -SimpleMatch
```

## Parameters

**-CaseSensitive SwitchParameter optional**

Use case-sensitive matching.

**-Extension String[] optionalsets: Path, LiteralPath**

Selected source extensions, with or without leading dots.

**-IncludePageLocations SwitchParameter optionalsets: Path, LiteralPath**

Compute Word and RTF page locations when supported.

**-MaximumFiles Int32 optionalsets: Path, LiteralPath**

Maximum selected files; zero means no limit.

**-MaximumResults Int32 optional**

Maximum total matches per document across all patterns; zero means no limit.

**-MaximumStoreItems Int32 optionalsets: Path, LiteralPath**

Maximum items projected from each mail store; zero means all.

**-Password SecureString optionalsets: Path, LiteralPath**

Open password for encrypted sources.

**-Path String[] requiredposition: 0pipeline: True (ByValue)sets: Path**

Gets or sets input paths with provider wildcard expansion.

**-Pattern String[] requiredposition: 1**

One or more regular expressions, or literal strings with SimpleMatch.

**-Reader OfficeDocumentReader optionalsets: Path, LiteralPath**

Use an immutable, caller-configured Reader.

**-Recurse SwitchParameter optionalsets: Path, LiteralPath**

Include subfolders.

**-SimpleMatch SwitchParameter optional**

Treat patterns as literal text.

**-ThrottleLimit Int32 optionalsets: Path, LiteralPath**

Gets or sets the maximum number of concurrent background operations.

**-WholeWord SwitchParameter optional**

Accept matches only at word boundaries.

**-InputObject OfficeDocumentReadResult requiredposition: 0pipeline: True (ByValue)sets: InputObject**

Normalized document to search without rereading a file.

**-LiteralPath String[] requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath**

Gets or sets input paths without wildcard expansion, binding FileInfo.FullName and provider PSPath.

## 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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

## Outputs

PSWriteOffice.Models.Reader.OfficeDocumentSearchMatch: PowerShell-friendly occurrence returned by a path-based document search.

<!-- PowerForge markdown artifact sha256:C6CC115AE07A5DF04E28B67EF4198D6939C1201C0759507300361694EB582D35 -->
