【发布时间】:2020-03-05 18:06:39
【问题描述】:
下面的 Powershell 脚本效果很好。它进入我的 eventviewer 日志,捕获过去 24 小时内特定 eventid 的所有事件并将其导出到临时文件。我现在正在尝试修改此脚本,以便它仅向我显示以下日期范围(2020 年 1 月 7 日 - 2020 年 2 月 6 日)的数据。对于我的生活,我无法弄清楚。有谁知道如何添加日期范围?
Get-WinEvent -ProviderName $ProviderName -MaxEvents 64000 -EA SilentlyContinue | Where-Object
$_.id -in $EventID -and $_.Timecreated -gt (Get-date).AddHours(-24)
} | Sort TimeCreated -Descending | Export-Csv $Path -NoTypeInformation
【问题讨论】:
-
对 SO 很陌生,您可能不知道这一点,但习惯于单击左侧的 ✓ 图标 accept the answer that solved your problem。这将帮助其他有类似问题的人更轻松地找到它,并有助于激发人们回答您的问题。
标签: powershell date-range event-viewer