用于在事件查看器中搜索任务名称的Windows 10 PowerShell脚本



希望创建一个PowerShell脚本,该脚本可以检查任务调度程序的Windows事件查看器日志。

特别是以PROD_和DEV_开头的任务

有没有办法对此使用通配符?

谢谢,

Shane

最简单的方法是过滤Get-WinEvent结果的Message属性:

Get-WinEvent -LogName 'Microsoft-Windows-TaskScheduler/Operational' |
Where message -match 'PROD_|DEV_'

只需使用-like或任何其他比较运算符。

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comparison_operators?view=powershell-7

最新更新