使用PowerShell检测切换用户

4
我想在机器上注册每次切换用户被调用的日期和时间。我该如何做到这一点?类似于此但针对“切换用户”事件:使用powershell检测注销和登录 提前感谢您。
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

我希望这可以帮到您。
JP
附注:您可以在此处找到有关“快速用户切换”的其他法语信息

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接