当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何检查谁重新启动(关闭)Windows Server

作者:精品下载站 日期:2024-12-14 23:33:00 浏览:17 分类:玩电脑

如何检查谁重新启动(关闭)Windows Server


如果您的公司有多个系统管理员,有时您可能想知道是谁重新启动了服务器。在本文中。我将向您展示如何通过事件日志识别重新启动或关闭运行 Windows 的计算机/服务器的用户。

有关发送重新启动命令的用户帐户的信息存储在 Windows 事件日志中。

  1. 打开事件查看器控制台(

    eventvwr.msc

    )并转到 Windows 日志 -> 系统

  2. 通过单击上下文菜单中的筛选当前日志来使用事件日志筛选器;

    [玩转系统] 如何检查谁重新启动(关闭)Windows Server

  3. 在过滤框中输入EventID 1074,然后单击“确定”;

    [玩转系统] 如何检查谁重新启动(关闭)Windows Server

  4. 只有关闭(重新启动)事件才会保留在日志列表中。打开最后一个事件;

  5. User32 作为源的事件显示发起 Windows 重新启动的用户。在这个例子中,它是用户

    novak

    ;

    [玩转系统] 如何检查谁重新启动(关闭)Windows Server

The process C:\Windows\Explorer.EXE has initiated the restart of computer MUN-DC03 on behalf of user WOSHUB\novak for the following reason: Other (Unplanned)
Reason Code: 0x5000000
Shutdown Type: restart
Comment:

使用 GPO,您可以允许非管理员用户重新启动 Windows Server。

让我们看一下 Windows 重启/关闭事件的更多示例。您可能会看到 NT AUTHORITY\SYSTEM 作为重新启动操作系统的用户。

这意味着重新启动是由作为系统运行的 Windows 服务或程序启动的。例如,它可能是一个wuauserv服务进程,它根据配置的Windows Update GPO设置或使用PSWindowsUpdate模块的任务完成了Windows更新并重新启动了计算机。

The process C:\Windows\uus\AMD64\MoUsoCoreWorker.exe has initiated the restart of computer MUN-DC03 on behalf of user NT AUTHORITY\SYSTEM for the following reason: Operating System: Service pack (Planned)
Reason Code: 0x80020010
Shutdown Type: restart
Comment:

如果您的 Windows 客户机在 VMware 虚拟机中运行,并且您在 VMware 管理控制台中运行重新启动客户机,则关闭事件如下所示:

The process C:\Program Files\VMware\VMware Tools\vmtoolsd.exe has initiated the shutdown of computer MUN-DC03 on behalf of user NT AUTHORITY\SYSTEM for the following reason: Legacy API shutdown
Reason Code: 0x80070000
Shutdown Type: shutdown

在这种情况下,Windows 关闭也由 NT AUTHORITY\SYSTEM 启动,因为 VMware Tools 集成服务代表系统运行。

您可以使用 PowerShell 获取有关重新启动事件的信息。以下命令显示 EventID 1074 的所有事件:

Get-WinEvent -FilterHashtable @{logname=’System’;id=1074}|ft TimeCreated,Id,Message

该命令返回所有 Windows 重新启动和关闭事件的描述。

[玩转系统] 如何检查谁重新启动(关闭)Windows Server

您可以使用以下 PowerShell 脚本返回最近十个事件的列表,其中包含启动服务器重新启动/关闭的用户或进程的名称。

Get-EventLog -LogName System |
where {$_.EventId -eq 1074} |select-object -first 10 |
ForEach-Object {
$rv = New-Object PSObject | Select-Object Date, User, Action, process, Reason, ReasonCode
if ($_.ReplacementStrings[4]) {
$rv.Date = $_.TimeGenerated
$rv.User = $_.ReplacementStrings[6]
$rv.Process = $_.ReplacementStrings[0]
$rv.Action = $_.ReplacementStrings[4]
$rv.Reason = $_.ReplacementStrings[2]
$rv
}
} | Select-Object Date, Action, Reason, User, Process |ft

[玩转系统] 如何检查谁重新启动(关闭)Windows Server

您可以使用 PowerShell 获取重新启动远程计算机的用户的名称。您可以使用 Get-EventLog -ComputerName 命令访问远程主机上的事件日志,或使用 Invoke-Command cmdlet 和 PSRemoting 连接到计算机:

Invoke-Command -ComputerName mun-dc03 -ScriptBlock {Get-WinEvent -FilterHashtable @{logname=’System’;id=1074} |select-object TimeCreated,Id,Message -first 1}

[玩转系统] 如何检查谁重新启动(关闭)Windows Server

通过事件ID 1074,您只能找到正确服务器重新启动的原因。如果 Windows 由于紧急情况(例如,电源故障或出现 BSOD)而重新启动,您必须搜索 EventID 6008

The previous system shutdown at 3:24:29 AM on ‎9/‎17/‎2022 was unexpected.

[玩转系统] 如何检查谁重新启动(关闭)Windows Server

当然,如果事件日志已被清除或者较新的事件已被较早的事件覆盖,您将无法找出是谁重新启动了 Windows(建议在域中使用 GPO 增加事件日志的最大大小)。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯