Active Directory export users in security group with select properties

NIT1100011 1 Reputation point
2022-05-25T16:50:07.86+00:00

I have a security group. All members in this group, and nested groups, I need to extract the display name, creation date, password last changed, and one or two other properties. The Get-ADGroupMembership does not contain these properties.

I am trying to do something like (I know this is way off but it illustrates the end goal logic to you I believe:

$sam= Get-ADGroupMember -id "Sample Security Group" -Recursive |select sama*

Get-ADUser -Properties * -id $sam |select name,whencreated,passwordlastset,enabled,lastlogondate

Windows for business Windows Client for IT Pros Directory services Active Directory
Windows for business Windows Server User experience PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2022-05-25T19:11:06.537+00:00

    I don't think you were too far off. Try this:

    Get-ADGroupMember -id "Sample Security Group" -Recursive |
        ForEach-Object{
            Get-ADUser -Properties * -id $_.samaccountname |
                Select-Object name,whencreated,passwordlastset,enabled,lastlogondate
        }
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.