【发布时间】:2018-04-26 03:20:49
【问题描述】:
我正在尝试为我们的帮助台代理创建一个基本脚本,这将允许他们查看特定的日志文件,而无需打开事件查看器以节省他们在电话上的时间。
但是,我在使用 PowerShell 时遇到问题,其中某些事件 ID 没有显示实际的事件日志消息。
如果我运行以下命令:
Get-EventLog -ComputerName $env:COMPUTERNAME `
-LogName System `
-InstanceId 12 `
-Source Microsoft-Windows-Kernel-General |
Select-Object -Property Message
我希望收到实际事件日志中显示的消息:
相反,我得到了一些类似的东西:
The description for Event ID '12' in Source
'Microsoft-Windows-Kernel-General' cannot be found. The local
computer may not have the necessary registry information or message
DLL files to display the message, or you may not have permission to
access them. The following information is part of the event:'10',
'0', '15063', '726', '0', '0',
'2018-03-18T16:59:34.495252300Z'
我看到另一个 thread 关于使用 Get-WinEvent 不幸的是,这在我工作的环境中是不可能的。
【问题讨论】:
-
您是否两次都在同一台计算机上查看事件?
-
我假设您想从消息中提取系统启动时间。在这种情况下,该数据仍处于您返回的“错误”中。它是消息中的最后一个字符串:
'2018-03-18T16:59:34.495252300Z'。不理想,但您可以像解析“真实”消息一样解析此字符串。 -
“这在我工作的环境中是不可能的”是什么意思?为什么不可能?
-
@EBGreen 是同一台计算机。
标签: powershell event-log