So...

$TheUsers = Get-QADGroupMember $GroupName -type 'user'
At this moment you have the user objects and their properties so let's try

$TheUsers | Get-Member

Looking at the Properties field there is a "AccountIsDisabled" property..
yay.  Lot's of other properties as well which is nice since you have
already paid the price for lookup.

$TheUsers = Get-QADGroupMember $GroupName -type 'user'
foreach ($user in $TheUsers) { if ($user.AccountIsdisabled -eq $false) {
Write-Output $user.name } }

That should work without the extra Get-QADUser lookup which will speed the
script up.
Steven Peck
http://www.blkmtn.org


On Fri, Oct 5, 2012 at 8:52 AM, Steven Peck <[email protected]> wrote:

>
> This will get only user type objects
> Get-QADGroupMember $GroupName -type 'user'
>
> This will get only user type objects AND users from any nested groups.
> Get-QADGroupMember $GroupName -type 'user' -indirect
>
> So if the rest of your script currently works that should be the only
> change you have to make to that part.
>
> I will point out that your use of the "Select Name" is destroying the
> object data in the pipeline.  It looks like you might be able to avoid that
> extra "$Employee = Get-QADUser $User.Name" user look up call.  I'd have to
> play with it more but I am trying to actually have an answer to a PoSH
> question before MBS gets in with the solution for once so I could be
> wrong.  :)
>
> Steven Peck
> http://www.blkmtn.org
>
>
>
> On Fri, Oct 5, 2012 at 8:36 AM, Michael Leone <[email protected]> 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 [email protected]
>> 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 [email protected]
> 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 [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to