AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 702828
Accepted
JohnC
JohnC
Asked: 2015-07-02 05:19:54 +0800 CST2015-07-02 05:19:54 +0800 CST 2015-07-02 05:19:54 +0800 CST

Windows Server 重启/关机历史

  • 772

如何轻松查看我的 Windows Server 每次重新启动或关闭的历史记录以及原因,包括用户启动、系统启动和系统崩溃?

Windows 事件日志是一个显而易见的答案,但我应该查看的完整事件列表是什么?

我发现这些帖子部分回答了我的问题:

  • Windows 服务器上次重新启动时间包括几个部分解决完整重新启动历史记录的答案
  • 查看 Windows Server 2008 R2 下的 Shutdown Event Tracker 日志包含一个额外的事件 id
  • 计算机启动/启动时的事件日志时间包括一些相同的事件 ID

但这些并没有涵盖所有场景 AFAIK 并且信息很难理解,因为它分布在多个答案中。

我有多个版本的 Windows Server,因此至少适用于 2008、2008 R2、2012 和 2012 R2 版本的解决方案将是理想的。

windows-server-2008
  • 6 6 个回答
  • 595986 Views

6 个回答

  • Voted
  1. Best Answer
    JohnC
    2015-07-02T05:19:54+08:002015-07-02T05:19:54+08:00

    我能找到的最清晰最简洁的答案是:

    • 如何在 Windows 中查看 PC 启动和关闭历史记录

    其中列出了要监视的这些事件 ID(引用但从文章中编辑和重新格式化):

    • 事件 ID 6005(备用):“事件日志服务已启动。” 这是系统启动的同义词。
    • 事件 ID 6006(备用):“事件日志服务已停止。” 这是系统关闭的同义词。
    • 事件 ID 6008(备用):“上一次系统关闭是意外的。” 系统未正常关闭后启动的记录。
    • 事件 ID 6009(备用):指示在启动时检测到的 Windows 产品名称、版本、内部版本号、服务包号和操作系统类型。
    • 事件 ID 6013:显示计算机的正常运行时间。此 ID 没有 TechNet 页面。

    从我的 OP 中列出的服务器故障答案中添加更多内容:

    • 事件 ID 1074(备用):“进程 X 已代表用户 Y 启动重新启动/关闭计算机,原因如下:Z。” 表示应用程序或用户启动了重新启动或关闭。
    • 事件 ID 1076(备用):“用户 X 提供的上次意外关闭此计算机的原因是:Y。” 记录第一个具有关机权限的用户在意外重新启动或关机后登录计算机的时间,并提供发生的原因。

    我错过了吗?

    • 127
  2. ocroquette
    2020-02-10T09:41:54+08:002020-02-10T09:41:54+08:00

    将@user10082评论变成答案。建议的解决方案是单行的,如 Powershell 脚本:

    Get-EventLog -LogName System |? {$_.EventID -in (6005,6006,6008,6009,1074,1076)} | ft TimeGenerated,EventId,Message -AutoSize –wrap
    

    这是输出:

    TimeGenerated         EventID Message
    -------------         ------- -------
    5/30/2021 11:23:16 AM    6005 The Event log service was started.
    5/30/2021 11:23:16 AM    6009 Microsoft (R) Windows (R) 10.00. 19042  Multiprocessor Free.
    5/30/2021 11:23:16 AM    6008 The previous system shutdown at 18:35:45 on ‎24/‎05/‎2021 was unexpected.
    5/24/2021 11:55:45 AM    6005 The Event log service was started.
    5/24/2021 11:55:45 AM    6009 Microsoft (R) Windows (R) 10.00. 19042  Multiprocessor Free.
    5/24/2021 11:55:31 AM    6006 The Event log service was stopped.
    5/24/2021 11:55:27 AM    1074 The process C:\Windows\system32\SystemSettingsAdminFlows.exe (DESKTOP) has
                                  initiated the restart of computer DESKTOP on behalf of user DESKTOP\User
                                  for the following reason: Other (Unplanned)
                                   Reason Code: 0x0
                                   Shutdown Type: restart
                                   Comment:
    
    • 16
  3. JTL
    2015-07-02T06:54:01+08:002015-07-02T06:54:01+08:00

    我只是将其作为评论留下,因为 JohnC 基本上涵盖了所有内容,但我还不允许这样做。

    他描述的事件已经使用了很长一段时间,因此它们适用于您提到的任何操作系统,以及它们的桌面兄弟。他链接到的事件 ID 页面,例如 TechNet 上的6006页面,提到了 Windows Server 2003。

    如果出现优雅关闭、用户启动或其他情况,您还应该看到一些事件 ID 7036告诉您各种服务“进入停止状态”。随着机器再次启动,您将看到更多的 7036 通知服务正在进入运行状态。

    • 4
  4. Rakaim
    2019-01-25T10:20:06+08:002019-01-25T10:20:06+08:00

    我更喜欢从命令行完成活动。这是您可以利用的片段的开头。这将显示最近的 30,000 条系统记录并返回这些记录中的重新启动。

    Get-EventLog -LogName System -Newest 30000 | Where-Object {$_.EventID -eq 6005}
    
    • 4
  5. elemer82
    2019-08-20T08:00:29+08:002019-08-20T08:00:29+08:00

    以@JohnC的回答为基础并对其进行扩展

    您可以使用 XML 过滤器,例如:

    <QueryList>
    <Query Id="0" Path="System">
    <Select Path="Security">*[System[Provider[@Name='eventlog' or @Name='Microsoft-Windows-Eventlog'] and (EventID=1074 or EventID=1076 or EventID=6005 or EventID=6006 or EventID=6008) and TimeCreated[timediff(@SystemTime) &lt;= 172800000]]]</Select>
    <Select Path="Setup">*[System[Provider[@Name='eventlog' or @Name='Microsoft-Windows-Eventlog'] and (EventID=1074 or EventID=1076 or EventID=6005 or EventID=6006 or EventID=6008) and TimeCreated[timediff(@SystemTime) &lt;= 172800000]]]</Select>
    <Select Path="System">*[System[Provider[@Name='eventlog' or @Name='Microsoft-Windows-Eventlog'] and (EventID=1074 or EventID=1076 or EventID=6005 or EventID=6006 or EventID=6008) and TimeCreated[timediff(@SystemTime) &lt;= 172800000]]]</Select>
    <Select Path="Microsoft-Windows-Kernel-Power/Diagnostic">*[System[Provider[@Name='Microsoft-Windows-Kernel-Power'] and (Level=1 ) and TimeCreated[timediff(@SystemTime) &lt;= 172800000]]]</Select>
    <Select Path="Microsoft-Windows-Kernel-Power/Thermal-Diagnostic">*[System[Provider[@Name='Microsoft-Windows-Kernel-Power'] and (Level=1 ) and TimeCreated[timediff(@SystemTime) &lt;= 172800000]]]</Select>
    <Select Path="System">*[System[Provider[@Name='Microsoft-Windows-Kernel-Power'] and (Level=1 ) and TimeCreated[timediff(@SystemTime) &lt;= 172800000]]]</Select>
    <Select Path="System">*[System[Provider[@Name='User32'] and TimeCreated[timediff(@SystemTime) &lt;= 172800000]]]</Select>
    <Select Path="System">*[System[Provider[@Name='Microsoft-Windows-WER-SystemErrorReporting'] and TimeCreated[timediff(@SystemTime) &lt;= 172800000]]]</Select>
    </Query>
    </QueryList>
    

    您可以将 172800000 替换为以下时间范围的值:

    86400000 - 过去 24 小时

    172800000 - 过去 2 天

    604800000 - 过去 7 天

    这将显示服务器/PC 离线时的更多详细信息。它包括 Kernel-Power、User32 和 EventLog 事件。

    • 4
  6. matt wilkie
    2021-02-06T15:24:42+08:002021-02-06T15:24:42+08:00

    psloglist使用 SysInternals和上面的事件 id 从远程机器获取最近 8 小时的重新启动和启动时间的简明一行:

    psloglist \\computername -h 8 -i 41,1074,1076,6005,6006,6008,6013
    

    唯一缺少的(对我来说)是“登录对话框准备好用户”等效的事件ID。这似乎很难找到(我可以查询什么以查看 Windows 是否已启动并完成更新?)

    • 0

相关问题

  • 文件复制到分支机构

  • 对于 ASP.Net 应用程序,Windows 64 位相对于 32 位的主要优势是什么?

  • Windows Server 2008 Hyper-V 虚拟化服务器的最佳 RAID 配置?

  • 远程连接 sql server 不工作,但如果防火墙禁用它呢?

  • 无法从 SQL Server 2008 备份数据库

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve