如何使用PowerShell获取一组用户的上次登录日期 [英] How to use PowerShell to get the last login date for a group of users
问题描述
新手PS问题:
如何使用PowerShell获取一组用户的上次登录日期?
这可能是我只是在密集,但我尝试了很多不同的方法,仍然无法得到结果。
我有一个函数将返回用户的最后登录日期/时间
PS C:\> Get-ADUserLastLogon -username Bob
Bob最后登录时间:4/1/2015 7:45:34 AM
我可以得到使用以下get-aduser命令的SharePoint相关用户列表:
Newbie PS question:
How to use PowerShell to get the last login date for a group of users?
This is probably me just being dense, but I've tried this a number of different ways and still can't get the results.
I have a function that will return the last logon date/time for a user
PS C:\> Get-ADUserLastLogon -username Bob
Bob last logged on at: 4/1/2015 7:45:34 AM
I can get the list of SharePoint related users with the following get-aduser command:
get-aduser -filter 'name -like "SP*" -or name -like "SharePoint*"' | get-aduser -properties * | select samaccountname
如何将用户列表中的结果传递到最后一次登录命令以获取完整的最后一次登录结果列表SharePoint用户?
How can I pipe the results from the user list in to the last logon command to get the full last logon result list for the SharePoint users?
推荐答案
这样的事情应该有效:
Something like this should work:
Get-ADUser -filter 'name -like "SP*" -or name -like "SharePoint*"' -Properties samAccountName,lastLogonDate
编辑: lastLogonDate
,不是 lastLogon
!前者返回 DateTime
,而后者返回 FILETIME [ ^ ]。
lastLogonDate
, not lastLogon
! The former returns a DateTime
, whereas the latter returns a FILETIME[^].
这篇关于如何使用PowerShell获取一组用户的上次登录日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!