PowerShell을 처음 사용하므로 어디서부터 시작해야할지 모르겠습니다. 특정 문자열 조합에 대한 모든 파일 내용 (pdf, word, excell, powerpoint, ...)을 검색하는 스크립트가 필요합니다. Powershell : 파일 내용 검색 및 텍스트 파일에 결과 쓰기
나는이 스크립트를 시도했지만 작동하지 않습니다 : 는function WordSearch ($sample, $staining, $sampleID, $patientID, $folder)
{
$objConnection = New-Object -com ADODB.Connection
$objRecordSet = New-Object -com ADODB.Recordset
$objConnection.Open(“Provider=Search.CollatorDSO;Extended Properties=’Application=Windows’;”)
$objRecordSet.Open(“SELECT System.ItemPathDisplay FROM SYSTEMINDEX WHERE ((Contains(Contents,’$sample’)) or (Contains(Contents,’$sampleID’) and Contains(Contents,’$staining’)) or (Contains(Contents,’$staining’) and Contains(Contents,’$patientID’))) AND System.ItemPathDisplay LIKE ‘$folder\%’”, $objConnection)
if ($objRecordSet.EOF -eq $false) {$objRecordSet.MoveFirst() }
while ($objRecordset.EOF -ne $true) {
$objRecordset.Fields.Item(“System.ItemPathDisplay”).Value
$objRecordset.MoveNext()
}
}
누군가가 나를 도울 수 있습니까?
왜'select-string'을 사용하지 않습니까? –
@ C.B. 이 기능은 텍스트 파일에서 제대로 작동하기 때문에 .doc 또는 특히 .docx 내에서 검색하려는 경우 작동하지 않습니다. –