Get-ADComputer and MemberOf
Your trouble comes from the fact that the primary group is not part of the memberOf
attribute.
So try this :
Get-ADUser -Filter * -Properties * | Select-Object -Property Name,MemberOf,PrimaryGroup | Sort-Object -Property Name
You'll find a deeper explanation in this answer.
Bobby
Updated on June 04, 2022Comments
-
Bobby almost 2 years
I am very new to Powershell and am having an issue when using the
Get-ADUser
andGetADComputer
cmdlets.I am trying to use the
Get-ADComputer
andGet-ADUser
to retrieve thememberOf
from Active-Directory of all the users and computers. It only appears to be retrieving information from users and computers that are in 2 or more groups. Any users/computers that are only in 1 group display nothing.For example: If UserA is in group Administrators I get no output when I use MemberOf. But if User2 is in both Administrators and Domains Administrators I get some output. However it will only output one of those groups.
Get-ADGroup does the same thing.
Is this normal? I can't imagine it is.
Here is my code:
Get-ADUser -Filter * -Properties * | Select-Object -Property Name,MemberOf | Sort-Object -Property Name
Thanks