Invalid Enumeration Context with Get-ADGroupMember

Welcome Forums General PowerShell Q&A Invalid Enumeration Context with Get-ADGroupMember

This topic contains 3 replies, has 3 voices, and was last updated by

2 years, 10 months ago.

  • Author
  • #42650

    Topics: 9
    Replies: 11
    Points: 0
    Rank: Member

    I am using the following command to query the count of all security groups in our domain:

    Get-ADGroup -Filter {name -notlike 'solution team iw'} | 
    select name, @{n='Member Count' ; e= {(get-adgroupmember $_.samaccountname -recursive).count }} | 
    export-csv C:\\adgroupmembercount.csv

    However, the command fails on one group, Solution Team IW.
    I am trying to exclude this group using the expression shown, but the command still returns the error "Invalid Enumeration Context".
    I'm guessing there's a corrupt AD object. But I can't remove this object as business operations depend on it.

    I've tried specifying another domain controller, but no luck.

    Any ideas on how you would workaround this issue?

  • #42654

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Have you tried just running the initial Get command to confirm that the group is being excluded from the results?

  • #42656

    Topics: 6
    Replies: 650
    Points: 2
    Rank: Member

    Hi Greg,
    Take a look at this article on Technet Wiki to see if it helps. I suspect, after looking at your code, you are running into this same issue.

  • #42695

    Topics: 9
    Replies: 11
    Points: 0
    Rank: Member

    You saved the day!

    This article helped me understand the issue (and taught me a new skill along the way with using TCPView in conjunction with measure-command).

    Ultimately, I was able to get the command to work by reducing the ResltPageSize from default 256 to a smaller number, 25.

The topic ‘Invalid Enumeration Context with Get-ADGroupMember’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort