locked
Size limit exceeded for Get-Adgroupmember RRS feed

  • Question

  • I have written this script to pull the members out of a group with over 5000 members. Everything seems to work fine until the export to csv. Can someone tell me what I am doing wrong? When it outputs to a csv I get no output at all. Or if someone else has a better idea I would be glad to hear it. The group does have spaces in it so it would be difficult to use LDAP

    Thanks in advance.

    Get-ADGroup "group1" -Properties Member | 
    Select-Object -ExpandProperty Member |
    Get-ADUser -ErrorAction SilentlyContinue
     @()| export-Csv "c:\test\groups.csv" -Delimiter ";" -Encoding UTF8 -NoTypeInformation


    Thanks for your help


    • Edited by jthomas777 Thursday, June 20, 2019 12:11 PM
    Thursday, June 20, 2019 12:01 PM

Answers

  • I fixed it myself. Sorry to have bothered you. By the way I have had formal education. I missed a couple of things. Thank you ever so much for your input.

    Get-ADGroup "group1" -Properties Member| 
    Select-Object -ExpandProperty Member |
    Get-ADUser -ErrorAction SilentlyContinue | Select Name, SamAccountName, Enabled | export-Csv "c:\test\groups.csv" 


    Thanks for your help

    • Marked as answer by jthomas777 Thursday, June 20, 2019 2:38 PM
    Thursday, June 20, 2019 2:37 PM

All replies

  • Get-Help Get-ADGroup -Online

    -ResultSetSize

    Specifies the maximum number of objects to return for an AD DS query. If you want to receive all of the objects, set this parameter to $Null (null value). You can use Ctrl+C to stop the query and return of objects.

    The default is $Null.

    Type: Int32
    "box-sizing:inherit;border-style:solid;border-color:var(--border);overflow-wrap:break-word;padding:14px 0px;line-height:1.5;vertical-align:top;border-width:1px 0px 0px;float:none;width:641px;">Named
    Default value: None
    Accept pipeline input: False
    Accept wildcard characters: False

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''

    Thursday, June 20, 2019 12:05 PM
  • My problem is the export to csv is not working. Can you assist with that?


    Thanks for your help

    Thursday, June 20, 2019 12:13 PM
  • @()| export-Csv "c:\test\groups.csv" -Delimiter ";" -Encoding UTF8 -NoTypeInformation
    What is that? You are sending an empty array to a csv file?

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''

    Thursday, June 20, 2019 12:32 PM
  • I thought I was piping the previous info to the csv file. How can I change it to work?

    Thanks for your help

    Thursday, June 20, 2019 12:59 PM
  • Remove the @() before the pipe, and you will be getting the Users info, not group

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''

    Thursday, June 20, 2019 1:21 PM
  • I tried that and it says an empty pipe element is not allowed

    At C:\Scripts\Group Membership.ps1:4 char:1

    + |export-Csv "c:\test\groups.csv" -Delimiter ";" -Encoding UTF8 -NoTyp ...

    + ~

    An empty pipe element is not allowed.

        + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

        + FullyQualifiedErrorId : EmptyPipeElement


    Thanks for your help

    Thursday, June 20, 2019 1:28 PM
  • Get-ADGroup "Group1" -Properties Member| 
    Select-Object -ExpandProperty Member |
    Get-ADUser -ErrorAction SilentlyContinue -Property Name, DisplayName 
    |export-Csv "c:\test\groups.csv" -Delimiter ";" -Encoding UTF8 -NoTypeInformation


    Thanks for your help


    • Edited by jthomas777 Thursday, June 20, 2019 1:35 PM
    Thursday, June 20, 2019 1:33 PM
  • My apologies, move the last pipe up one line 

    Get-ADGroup "group1" -Properties Member| 
    Select-Object -ExpandProperty Member |
    Get-ADUser -ErrorAction SilentlyContinue -Property Name, DisplayName |
    export-Csv "c:\test\groups.csv" -Delimiter ";" -Encoding UTF8 -NoTypeInformation


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''

    Thursday, June 20, 2019 2:03 PM
  • That is now giving me information in the csv. However it is giving me all the info not the specic fields I am looking for. How do I get it to just output the name and display name?

    Thanks for your help

    Thursday, June 20, 2019 2:14 PM
  • I said you will only get the user information, and you never specified which information you actually want. We are here to help with issues, not write scripts.

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''

    Thursday, June 20, 2019 2:23 PM
  • Before attempting to write PowerShell code you must take the time to learn basic PowerShell.  Asking others to do your learning for you is unfair and unprofessional.

    Start here:

          Microsoft Virtual     Academy - Getting Started with Microsoft PowerShell

          PowerShell Documentation

          PowerShell Style   Guidelines


    \_(ツ)_/

    Thursday, June 20, 2019 2:27 PM
  • I fixed it myself. Sorry to have bothered you. By the way I have had formal education. I missed a couple of things. Thank you ever so much for your input.

    Get-ADGroup "group1" -Properties Member| 
    Select-Object -ExpandProperty Member |
    Get-ADUser -ErrorAction SilentlyContinue | Select Name, SamAccountName, Enabled | export-Csv "c:\test\groups.csv" 


    Thanks for your help

    • Marked as answer by jthomas777 Thursday, June 20, 2019 2:38 PM
    Thursday, June 20, 2019 2:37 PM
  • If that is what you are trying to do you need to ask the question correctly.

    Get-AdGroupMember 'domain users' | 
        Where-Object{$_.objectClass -eq 'User'} |
        Get-AdUser | 
        Select Name, SamAccountName, Enabled |
        Export-Csv c:\test\groups.csv

    Learning PowerShell would teach you the correct syntax.  Not knowing the basic syntax of simple commands will make your life more difficult.

    Your code is basically going around the barn twice to get to the front door.  This is because you haven't learned the basics and do not know where to look when stuck.

    Here is where to start with AD: https://docs.microsoft.com/en-us/powershell/module/addsadministration/?view=win10-ps


    \_(ツ)_/


    • Edited by jrv Thursday, June 20, 2019 2:56 PM
    Thursday, June 20, 2019 2:54 PM
  • This is where this originally started. If you reference my original comments get-adgroupmember has a limit of 5000 entries. This is why I had to create a script to get around that. Your script takes me back to my original issue.

    Get-AdGroupMember : The size limit for this request was exceeded



    Thanks for your help

    Thursday, June 20, 2019 3:07 PM
  • The other script I created to work around this

    $grp = get-adgroup "group1" -properties members 
    $grp.members | get-aduser | Select Name, SamAccountName, Enabled | Export-csv "c:\test\groups.csv"

    But your right I need to learn basic powershell :)


    Thanks for your help

    Thursday, June 20, 2019 3:10 PM
  • Ha Ha  🧐🧕🧐🧓🧞🤟🤥🤩

    \_(ツ)_/

    Thursday, June 20, 2019 5:55 PM