powershell - Get-WinEvent 中消息的 grep 字符串

标签 powershell

我有一个脚本来检查 get-winevent 中的事件日志,我需要根据消息列中的搜索字符串显示 get-winevent 输出的完整结果.

有没有办法在get-winevent中grep消息列

这是当前字符串

Get-WinEvent -ComputerName $Target_Machine -FilterHashtable $params

最佳答案

您可以将输出管道化到Where-对象,请参见下面的示例:

$SearchString="AutoConfig"                                                                                                                                                                             
Get-WinEvent Microsoft-Windows-WLAN-AutoConfig/Operational | Where-Object{$_.Message -like "*$SearchString*"}    

关于powershell - Get-WinEvent 中消息的 grep 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45376593/

相关文章:

Powershell密码解密

powershell - Powershell 的 New-Alias 和 Set-Alias cmdlet 之间有什么区别?

regex - 移动与给定正则表达式匹配的目录

powershell - 变量替换 - 引用不起作用

powershell - bat 文件禁止用户输入

excel - 将代码从 Excel 宏转换为 PowerShell

powershell - 监控无效文件名并设置警报

powershell - 确定脚本中两点之间定义的函数

c# - 如何使用用户输入的字符串参数从 C# 安全地执行 powershell 脚本?

powershell - Powershell FTP不会列出服务器上的文件