4

我想注册每次在机器中调用切换用户的日期和时间。我怎样才能做到这一点?与此类似,但针对“切换用户”事件:使用 powershell 检测注销和开启

先感谢您

4

1 回答 1

3

我认为您正在寻找的是:

Event ID 4778 : A user has logged by selecting Switch user command (Fast User Switching).
Event ID 4779 : A user has logged back on using Switch user command (Fast User Switching).

但这些事件仅在您在审计策略中配置“审计连接事件”时才会出现在“安全”事件日志中。

在此处输入图像描述

对不起法国屏幕,但我认为这总比没有好。

之后,当使用“快速用户切换”时,如果您过滤事件 ID 4778 和 4779,您会看到如下内容:

在此处输入图像描述

因此,您在问题中指出的代码的 powerShell 改编类似于:

clear-Host
$UserProperty = @{n="User";e={$_.ReplacementStrings[0]}}
$TypeProperty = @{n="Action";e={switch($_.EventID) {4778 {"SwitchOn"} 4779{"SwitchOff"}}}}
$TimeProeprty = @{n="Time";e={$_.TimeGenerated}}
Get-EventLog -LogName Security -Source Microsoft-Windows-security-auditing | where {$_.EventID -eq 4778 -or $_.EventID -eq 4779} | select $UserProperty,$TypeProperty,$TimeProeprty

我希望这有帮助。

J.P

PS:您可以在此处找到有关法语“快速用户切换”的其他信息

于 2011-03-18T09:11:21.737 回答