 |
|
|
Filtering a select-object
Last Post 29 Oct 2010 06:09 AM by Jonathan. 1 Replies.
|
Sort:
|
|
Prev Next |
You are not authorized to post a reply. |
|
adrian
 New Member Posts:1

 |
| 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 |
|
|
|
|
Jonathan
 Basic Member Posts:109

 |
| 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
|
|
 |