Get-ADComputer and MemberOf

11,332

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.

Share:
11,332
Bobby
Author by

Bobby

Updated on June 04, 2022

Comments

  • Bobby
    Bobby almost 2 years

    I am very new to Powershell and am having an issue when using the Get-ADUser and GetADComputer cmdlets.

    I am trying to use the Get-ADComputer and Get-ADUser to retrieve the memberOf 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