我有一個文件夾包含多個excell文件,我想搜索一個字符串,如「2501」和anf find文件有這個,然後輸出它的文件名稱到一個文件或顯示)。我寫了一些腳本並搜索了一些,但沒有找到答案。如何在excell中使用powershell搜索字符串
我寫了這個:
$Location = "C:\1.xlsx"
$SearchStr = "Mike"
$Sel = Select-String -pattern $SearchStr -path $Location
If ($Sel -eq $null)
{
write-host "$Location does not contain $SearchStr" -ForegroundColor Cyan
}
Else
{
write-host "Found $SearchStr `n$Se in $Location"
}
Write-host "end" -ForegroundColor Yellow
如果我指定txt文件這隻適用,它不與Excel工作。
我會感謝所有幫助我的人。
另一個例子,與txt文件的工作原理>>獲取內容C:\腳本\ test.txt的|選擇字符串「失敗」 – PouriaJalilian
https://stackoverflow.com/questions/30200920/finding-content-of-excel-file-in-powershell –