0
おはようございます、私はpowershellを初めて使っています。powershellを使用して特定のフレーズをフォルダから見つける方法
私はいくつかのフォルダから.doc、.docxで特定のフレーズを検索する方法を知りましたが、私が探しているものを正確に見つけることができません。例えば
、私はこのコード
Get-ChildItem 'C:\Users\koshiasu\Desktop\adhocs' -Filter *.sql |Select-String -Pattern "children"
を実行したときには、この私のPowerShellの底に
結果1
Desktop\adhocs\18722 Parents.sql:11: AND EXISTS (SELECT c.id_number FROM children c
Desktop\adhocs\18722 Parents.sql:38: AND EXISTS (SELECT c.id_number FROM children c
Desktop\adhocs\2969 ADHOC - Parents in Dallas.sql:11: AND EXISTS (SELECT c.id_number FROM children c
Desktop\adhocs\2969 ADHOC - Parents in Dallas.sql:92: AND EXISTS (SELECT c.id_number FROM children c
のように私は.DOCのために同じことをしたいと思い示し、.docx
だから私はこのようなコードを変更しました
Get-ChildItem 'C:\Users\koshiasu\Desktop\ADHOCS_WORD' -Filter *.doc, *.docx |Select-String -Pattern "Allocations"
が、エラーが、私は結果1のように表示するようにコードを変更する方法
Get-ChildItem : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Filter'. Specified method is not supported.
At line:2 char:58
+ Get-ChildItem 'C:\Users\koshiasu\Desktop\ADHOCS_WORD' -Filter <<<< *.doc, *.docx |Select-String -Pattern "Allocations"
+ CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.GetChildItemCommand
ある
はどうもありがとうございます
私は基本的に、転がっ同じ片付けた何かのためのコードを持っていた
'Get-ChildItem -Filter'は1つのフィルタパターンしか受け付けません。代わりに' Get-ChildItem | Where-Object {'.doc'、 '。docx' -contains $ _。Extension} | Select-String ... ' 。それはおそらく動作しません。 '.docx'ファイルは基本的にXML文書のzipフォルダですが、正規表現は使用しません –