powershell - 如何在powershell中使用findstr在整个驱动器中搜索字符串?

标签 powershell

因此,我接到了在网络安全实验室中查找特定日志文件的任务。我的目的是找到一个密码工具的日志文件,其中包含一个名为 Alan Jones(用户名 alan.jones)的人的信息。

我已经获得了使用 findstr 命令的线索,但是,这仅对搜索一个目录有用。

有没有办法使用 findstr 让 powershell 在整个驱动器中搜索特定字符串?

最佳答案

如果您打算使用 PowerShell,我建议您坚持使用 native cmdlet,而不是使用 findstr。 , Select-String可以做你想做的事:
Get-ChildItem C:\*.log -Recurse | Select-String -Pattern "alan\.jones"
有关 Select-String 运行的更多信息Get-Help Select-String -Online

关于powershell - 如何在powershell中使用findstr在整个驱动器中搜索字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58889324/

相关文章:

powershell - GitHub 操作 : Pass Environment Variable to into Action using PowerShell

powershell - 针对多个服务器运行脚本,但结果乱序

powershell - 无法从函数内部修改脚本范围的变量

file - 这个powershell脚本是找到所有者然后更改所有者的好方法吗

powershell - 让 psessions 为 txt 文件中列出的多个服务器正确循环时出现问题

arrays - PowerShell在CSV中查找重复项并输出不同的标题

excel - 使用powershell查找word和excel文档的最后保存者

powershell - powershell 5.0 和 5.1 中的 Get-ChildItem

powershell - 您能否在发布管理中将一个 PowerShell 任务的输出通过管道传输到另一个任务?

powershell - 当我已经定义了变量时出现意外的 token 错误