figured out this to find who was in the group:
Get-ADGroupMember “companyGroup” | Select-Object SamAccountName
this gave me a list but I found some users in it that was no longer with the company so I wanted to change it to find users who was not with the company anymore. So I thought why not use disabled users to find out who we should remove.
the problem is that adgroupmember only has properties for
so I went and first checked out the help
get-help get-adgroupmember -full however that did not get me enough information to help me.
I then thought maybe I am approaching this from the wrong way. I started thinking I needed to first get my users (even though it would use more processor) and from that distil it down to the group members so I tried this:
Get-ADUser -Filter ‘Enabled -eq $false’ -Properties SamAccountName |Select-Object SamAccountName
and this did give me the disabled users that I needed.
So then I tried to put it together but I am struggling now and its not working as witnessed below where I thought to use parenthesis first to make perform that operation then go to the next.
Get-ADGroupMember “G_CompanyGroup” | Select-Object SamAccountName (Get-ADUser -Filter ‘Enabled -eq $false’ -Properties SamAccountName |Select-Object SamAccountName)