我有一个文件夹包含多个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 –