Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Search-OfficeDocument

Module
PSWriteOffice
Inputs
OfficeIMO.Reader.OfficeDocumentReadResult System.String[]
Outputs
PSWriteOffice.Models.Reader.OfficeDocumentSearchMatch

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>]
#
Parameter set: Path
Search-OfficeDocument
[-CaseSensitive]
[-InputObject] <OfficeDocumentReadResult>
[-MaximumResults <Int32>]
[-Pattern] <String[]>
[-SimpleMatch]
[-WholeWord]
[<CommonParameters>]
#
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>]
#
Parameter set: LiteralPath

Examples

Find invoice identifiers in a mixed folder.

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

Find literal text in an already read document.

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.

Outputs

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