How do I make powershell search a Word document for wildcards and return the word it found?

前端 未结 1 1825
猫巷女王i
猫巷女王i 2020-12-22 04:52

I am searching a very large amount of Word documents (5000) for a very large number of strings (3000). I know how to do this in a Powershell script, but it takes an extreme

相关标签:
1条回答
  • 2020-12-22 05:02

    Instead of using Word's wildcard searching why not just use a Powershell regex on all of the text in the document. Something like this:

    if ($document.Content.Text -match "\b$($findText)\w+\b") 
    { 
      $docName = $doc.Name
      "$($matches[0])`t$docName" | Out-File -append $outputPath   
    }
    
    0 讨论(0)
提交回复
热议问题