I'm trying to get@{n='Active';e={(Get-ADGroupMember $group | get-aduser -Properties enabled |select enabled).enabled}}
to read the samaccount name and return whether the user is enabled or disabled. However the code returns true and false for all members in the group. How do I get it to return result for just the user in 1st column in my results?
Below is my full script with the results I get.
$groups = "some","ad", "groups"
$results = foreach ($group in $groups) {
Get-ADGroupMember $group | select samaccountname, @{n='GroupName';e={$group}}, @{n='Description';e={(Get-ADGroup $group -Properties description).description}}, @{n='Active';e={(Get-ADGroupMember $group | get-aduser -Properties enabled |select enabled).enabled}}
}
$results
Results: