header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Filtering a select-object
Last Post 29 Oct 2010 06:09 AM by Jonathan. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
adrianUser is Offline
New Member
New Member
Posts:1
Avatar

--
22 Sep 2009 05:11 AM
    Hey all,

    Fairly new to PS, so sorry if my question is a bit silly.

    I am writing a basic script to output some info to html. 

    What i want is to apply a filter to one of the criteria i specify after i pipe the users to the select-object command.  here is what i have...

    get-qaduser -all -sizelimit 0 | select-object samaccountname, displayname, homemdb, mail, altrecipient, memberof | sort-object displayname -descending

    All fine, but i only want Distribution Groups to be outputted from the memberof.  And i also want the displayname of the group and not the DN, which is what i get at the moment.

    As i said, i am pretty new to PS and i have tried to find some answers to this to no avail.  I understand how to use the where-object but not sure how/if to use with the select-object.

    Hope someone can help!

    thanks a lot
    Adrian
    JonathanUser is Offline
    Basic Member
    Basic Member
    Posts:109
    Avatar

    --
    29 Oct 2010 06:09 AM
    I just found your question and thought I might be able to help.  I know it has been a long time since you posted this, but perhaps you or someone else can benefit from this answer.

    Ok, so it looks like you are really close to getting this...you need to use a calculated property for the group name.  For example, your query might look like this...

    get-qaduser -all -sizelimit 0 | select-object samaccountname, displayname, homemdb, mail, altrecipient, @{Name="Dist Lists";Expression={$_.MemberOf | get-qadgroup | Where-Object {$_.GroupType -eq "Distribution"} | select-object -expand Name}} | sort-object displayname -descending | format-table -auto

    Hope this helps
    Jonathan Tyler
    http://powershellreflections.wordpress.com
    Follow Me On Twitter
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer