如何使用powershell在docx文件中搜索单词?

Lav*_*son 3 powershell

我必须检查文件夹中的所有 .docx 文件,并且必须显示包含我作为参数添加的单词的文件名。我怎样才能在powershell中做到这一点?

Esp*_*o57 7

尝试这样的事情:

\n\n
#Instance of word\n$Word=NEW-Object \xe2\x80\x93comobject Word.Application\n$Word.visible = $False\n\n#take list of .docx\nGet-ChildItem "c:\\temp" -file -Filter "*.docx" | %{\n\n$Filename=$_.FullName\n\n#open file and take content of word file\n$Document=$Word.documents.open($Filename, $false, $true)\n$range = $document.content\n\n#if content have your word, print path of word file\nIf($range.Text -like "*tot*"){\n    $Filename\n}\n\n$word.Documents.Close($false)\n\n}\n
Run Code Online (Sandbox Code Playgroud)\n