通过 Powershell 在 Windows 中找出上次登录时间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1272272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Finding out Last logon time in Windows through Powershell
提问by BlueGene
How do you find out the last log-in time for a windows machine(any user) through powershell?
你如何通过powershell找出windows机器(任何用户)的最后登录时间?
采纳答案by Tom Ritter
It's apparently non-trivialwhen you involve domain controllers. Here's the code ripped from that blog entry (first one on google, by the way)
当您涉及域控制器时,这显然很重要。这是从该博客条目中提取的代码(顺便说一下,这是谷歌上的第一个)
Without a Domain Controller:
没有域控制器:
(Get-QADUser username).lastLogon
With:
和:
Get-QADComputer -ComputerRole
DomainController | foreach {
(Get-QADUser -Service $_.Name
-SamAccountName username).LastLogon.Value } |
Measure-Latest