I think this should work for you:
$TheUsers = Get-QADGroupMember $GroupName | where {$_.type -eq 'user'} |
Select Name | Sort Name

On Fri, Oct 5, 2012 at 11:36 AM, Michael Leone <oozerd...@gmail.com> wrote:

> I'm confused about something. I am writing a Powershell script, using
> the Quest AD CMDLETs. I have a list of groups that I need to retrieve
> the membership list for. But I don't want any group members that are
> themselves groups (i.e., no nested groups); I only want users. And I
> am not sure how best to accomplish this. At the moment, my script
> loops thought my list of groups, and I get the list of names who are
> members:
>
> $TheUsers = Get-QADGroupMember $GroupName | Select Name | Sort -property
> Name
>
> I then loop through the returned user list and output individual user
> accounts that are not disabled into a spreadsheet.
>
>         ForEach ($User in $TheUsers)
>                 {
>                 $Employee = Get-QADUser $User.Name
>                 $DisabledUser = $Employee.AccountIsDisabled
>                 IF ( $DisabledUser -eq $false )
>                         {
>                         $Cells.Item($CurrentRow, $CurrentCol) =
> $GroupCounter
>
> (I don't want to make the pipelining too complicated, in case the
> other guys need to maintain this script in my absence)
>
> And so forth. But what I don't know is how to determine that $Employee
> is a person and not a group. I'm sure it's simple and pretty much
> staring me in the face, but I'm not seeing it. Groups have no
> "AccountIsDisabled" property, apparently, so any groups who are
> members of the group I am searching are not falling through into the
> section that formats the spreadsheet.
>
> SO: when I do a "Get-QADUser <someuser>", what property should I be
> looking at  to determine that "<someuser>" is actually a group? Then I
> can modify my IF statement appropriately.
>
> Thanks, and sorry for being such a n00b at this ...
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to listmana...@lyris.sunbeltsoftware.com
> with the body: unsubscribe ntsysadmin
>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

Reply via email to