locked
Get-ADGroup -Properties RRS feed

  • Question

  • I am trying to output only the Name property of a list of AD groups. I am using the following -

    Get-ADGroup -Filter{name -like "ORG-*"} -Properties Name -SearchBase "ou=Test ,dc=test,dc=test"

    The -Properties parm doesnt seem to work except by using an *. I either get the default set of properties or I can get them all with a *.

    Thanks. Slag

    Thursday, August 9, 2012 3:58 PM

Answers

  • Name is actually part of the default property set, so no real need to specify it in the syntax.  the -Properties parameter is only used to include attributes that are not part of the default set, the default properties are: DistinguishedName,GroupCategory,GroupScope,Name,ObjectClass,ObjectGUID,SamAccountName, and SID.

    So, I would just leave that out and use '| Select-Object Name'  at the end to capture only the Name of the groups, or you could use '|Format-Table Name,GroupScope,GroupCategory' to format the output of your command to give a bit more usable info.

    If you are going to use the command to load the names into an array you will have to use the Select-Object method if you want an array of just the group names that match your criteria.

    • Marked as answer by Slag Thursday, August 9, 2012 5:24 PM
    Thursday, August 9, 2012 4:47 PM

All replies

  • Get-ADGroup -Filter{name -like "ORG-*"} -Properties Name -SearchBase "ou=Test ,dc=test,dc=test" | Select-Object Name


    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.

    Thursday, August 9, 2012 4:10 PM
  • Name is actually part of the default property set, so no real need to specify it in the syntax.  the -Properties parameter is only used to include attributes that are not part of the default set, the default properties are: DistinguishedName,GroupCategory,GroupScope,Name,ObjectClass,ObjectGUID,SamAccountName, and SID.

    So, I would just leave that out and use '| Select-Object Name'  at the end to capture only the Name of the groups, or you could use '|Format-Table Name,GroupScope,GroupCategory' to format the output of your command to give a bit more usable info.

    If you are going to use the command to load the names into an array you will have to use the Select-Object method if you want an array of just the group names that match your criteria.

    • Marked as answer by Slag Thursday, August 9, 2012 5:24 PM
    Thursday, August 9, 2012 4:47 PM
  • Thanks Russ. I am very new to PS and this was just what I needed.

    Thursday, August 9, 2012 5:26 PM
  • Not a problem, we were all new at one point, just some of us cant remember when :)
    Thursday, August 9, 2012 9:04 PM