Cmdlet
Find-OfficeWord
Finds text matches inside a Word document.
Syntax
Find-OfficeWord
[-CaseSensitive]
[-Path] <String>
[-Text] <String>
[<CommonParameters>]#Parameter set:
PathTextFind-OfficeWord
[-AsResult]
[-CaseSensitive]
[-Path] <String>
[-Pattern] <String>
[<CommonParameters>]#Parameter set:
PathRegexFind-OfficeWord
[-CaseSensitive]
-Document <WordDocument>
[-Text] <String>
[<CommonParameters>]#Parameter set:
DocumentTextFind-OfficeWord
[-AsResult]
[-CaseSensitive]
-Document <WordDocument>
[-Pattern] <String>
[<CommonParameters>]#Parameter set:
DocumentRegexDescription
Returns matching paragraphs or a WordSearchResult when using regex with -AsResult.
Examples
Find matching paragraphs and export a review list.
$matches = Find-OfficeWord -Path .\Report.docx -Text 'Quarter'
$matches |
Select-Object -Property Text |
Export-Csv -Path .\ReviewMatches.csv -NoTypeInformationFinds paragraphs containing the search text and writes a lightweight review CSV.
Use regex and keep the grouped WordSearchResult.
$result = Find-OfficeWord -Path .\Report.docx -Pattern 'FY\d{4}' -AsResult
$result.Paragraphs |
Select-Object -Property TextReturns the full regex result so paragraphs, table matches, headers, and footers can be inspected separately.
Parameters
- -CaseSensitive SwitchParameter
- Use case-sensitive matching.
- -Path String
- Path to the .docx file.
- -Text String
- Text to find.
- -AsResult SwitchParameter
- Emit the full WordSearchResult result for regex searches.
- -Pattern String
- Regular expression pattern to find.
- -Document WordDocument
- Word document to search.
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.