简体   繁体   English

使用WQL从WMI查询Win32_NTLogEvent类时,TimeGenerated属性是否基于计算机或GMT的本地时间?

[英]When querying the Win32_NTLogEvent Class from WMI with WQL is the TimeGenerated property based on Local time of the computer or GMT?

I am writing a C# windows service that is doing some churning through the eventlog on a few domain controllers. 我正在编写一个C#Windows服务,该服务正在通过一些域控制器上的eventlog进行一些改动。 Some of them are Windows Server 2003 and some are Windows Server 2008. Upon the service stopping I am attempting to resume where I left off in the logs. 其中有些是Windows Server 2003,有些是Windows Server2008。服务停止后,我尝试恢复在日志中停下来的位置。 In order to do this instead of 为了做到这一点,而不是

SELECT * FROM Win32_NTLogEvent WHERE --criteria for events I am looking for

I am doing 我在做

SELECT * FROM Win32_NTLogEvent WHERE TimeGenerated = --some date AND --criteria for events I am looking for

At one point I was convinced that the TimeGenerated field was in the local time of the server but now it seems that the Windows 2008 Servers are using GMT to record that time. 有一次我确信TimeGenerated字段位于服务器的本地时间,但是现在看来Windows 2008 Server使用GMT来记录该时间。 Can anyone shed some light on if this is a real different between the way the two operating systems function or is this a configuration problem? 如果这是两个操作系统的运行方式之间确实存在真正的区别还是这是配置问题,那么谁能提供一些启发?

In addition, it seems that in versions prior to Windows Server 2008 TimeGenerated was returned in local time, but changed to GMT in Server 2008, as others have been noticing. 此外,似乎在Windows Server 2008之前的版本中,TimeGenerated是在本地时间返回的,但正如其他人所注意到的,在Server 2008中已更改为GMT。

Windows time stamps are always recorded in UTC. Windows时间戳始终以UTC记录。 They will only be converted to local time in whatever GUI program you use to look at the data, like Event Viewer or Explorer (for file times). 它们只会在您用来查看数据的任何GUI程序中转换为本地时间,例如Event Viewer或Explorer(用于文件时间)。 This behavior is important to avoid random failure on daylight saving time transitions. 此行为对于避免夏令时过渡时发生随机故障很重要。

Something like this may be helpful: 这样的事情可能会有所帮助:

("Select * from Win32_NTLogEvent Where Logfile = 'Application' AND EventCode = '999' AND Message Like '%message%' AND TimeGenerated = '201202210000000000.000000+***'")

The TimeGenerated syntax is setup backwards so in the above example its yearmonthdaytimeminutesseconds.000000+\\*** the preceding 000000+\\*** is needed. TimeGenerated语法是向后设置的,因此在上面的示例中,需要它的yearmonthdaytimeminutesseconds.000000+\\***之前的000000+\\***

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Win32_NTLogEvent WHERE Logfile ='Security'上的查询仅在远程计算机上有效 - query on Win32_NTLogEvent WHERE Logfile = 'Security' works only on remote machine 为什么“Win32_CDROMDrive”类的“SerialNumber”属性在与WMI分开请求时返回null? - How come the “SerialNumber” property of the “Win32_CDROMDrive” class returns null when asking for it separately from WMI? 快速替换Win32_NetworkAdapter WMI类以获取本地计算机的MAC地址 - Fast replacement for Win32_NetworkAdapter WMI class for getting MAC address of local computer 查询WMI类Win32_ShadowCopy时初始化失败 - Initialization failure when querying WMI-class Win32_ShadowCopy Win32_ComputerSystem WMI类的SystemType属性的值奇怪吗? - Strange values of SystemType property of Win32_ComputerSystem WMI class? WMI - 来自 Win32_Product 的 select 需要很长时间 - WMI - select from Win32_Product takes a long time Win32_DiskDrive上的WQL查询无效 - Invalid WQL Query on Win32_DiskDrive 如何从Win32_CDROMDrive WMI类获取接口类型? - How to get the interface type from Win32_CDROMDrive WMI class? 如何通过 WMI 从“Win32_ProcessStopTrace”类获取附加信息? - How to obtain additional info from the 'Win32_ProcessStopTrace' class through WMI? C# WMI 方法 IsActivated 从 Win32_Tpm class 抛出“无效的方法参数” - C# WMI method IsActivated from Win32_Tpm class throws "Invalid method Parameter(s)"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM