windows – 使用Powershell,比较两个事件的TimeCreated值,如果一
发布时间:2020-12-13 23:16:12 所属栏目:Windows 来源:网络整理
导读:我创建了自己的事件日志,名为ScriptEvents,我使用一些脚本来写入.我想做的是运行这些命令(或类似的东西): Get-WinEvent -FilterHashtable @{logname='ScriptEvents'; id=1} -MaxEvents 1Get-WinEvent -FilterHashtable @{logname='ScriptEvents'; id=0} -Ma
我创建了自己的事件日志,名为ScriptEvents,我使用一些脚本来写入.我想做的是运行这些命令(或类似的东西):
Get-WinEvent -FilterHashtable @{logname='ScriptEvents'; id=1} -MaxEvents 1 Get-WinEvent -FilterHashtable @{logname='ScriptEvents'; id=0} -MaxEvents 1 然后比较他们的TimeCreated值并在第一个事件早于第二个事件时执行操作. 这是这些命令的输出: ProviderName: PauseSnapshots TimeCreated Id LevelDisplayName Message ----------- -- ---------------- ------- 9/26/2013 11:58:07 AM 1 Information Replication has been paused.... ProviderName: ResumeSnapshots TimeCreated Id LevelDisplayName Message ----------- -- ---------------- ------- 9/26/2013 1:30:42 PM 0 Information Replication has been resumed.... 任何帮助,将不胜感激.
我可能只是使用Get-Date并比较DateTime对象.以下将使用您提供的值返回True.
$evtOne = Get-WinEvent -FilterHashtable @{logname='ScriptEvents'; id=1} -MaxEvents 1 $evtTwo = Get-WinEvent -FilterHashtable @{logname='ScriptEvents'; id=0} -MaxEvents 1 (Get-Date $evtOne.TimeCreated) -lt (Get-Date $evtTwo.TimeCreated) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- .net-4.0 – windows xp上的visual studio 2013
- Windows在调用Main()之前做了什么?
- 如何在不看到Microsoft标头的情况下运行WSH脚本?
- 在windows netstat结果中“::”表示什么?
- 使用Windows XP和两个单独的Linux安装对双启动进行分区建议
- sublimetext2 – Sublime Linter在Windows中不工作
- Windows – 如何在x64上为我的进程启用对齐异常?
- windows-server-2003 – 为什么“本地安全策略”设置变灰?
- windows-7 – WPA2 Personal – 通过GPO部署
- windows – 打印服务器如何工作?