如何获取用户加入群组的日期?

我已经自动化了我们的更改程序并检查了用户组。如果他们已经添加到组中,脚本将检测到这一点并且不会将用户添加到组中。但是,我们希望在更改过程之前将该用户添加到组中的时间进行记录,以便我们找出发生这种情况的原因。

有没有一种方法可以查询组的成员列表以了解添加成员的日期?

stack overflow How to get the date of when the user was added to group?
原文答案

答案:

作者头像

这个脚本很棒

https://gallery.technet.microsoft.com/scriptcenter/Find-the-time-a-user-was-a0bfc0cf

只需运行脚本并查找组详细信息

Get-ADGroupMemberDate -Group 'Domain Admins'
作者头像

事件日志可能会拯救您。 4728/4729 > A member was added/removed to/from a security-enabled global group 4732/4733 > A member was added/removed to/from a security-enabled local group 4756/4757 > A member was added/removed to/from a security-enabled universal group 4751/4752 > A member was added/removed to/from a security-disabled global group (distribution list) 4746/4747 > A member was added/removed to/from a security-disabled local group (distribution list) 4761/4762 > A member was added/removed to/from a security-disabled universal group (distribution list)

Get-EventLog -logname security | Where-Object {($_.eventid -eq 4732) -or ($_.eventid -eq 4733 ) -or ($_.eventid -eq 4746)} | select EventID,MachineName,EntryType,Message,InstanceId,TimeGenerated,Timecreated,UserName | fl | export-csv -path C:logs.csv