- June 2, 2016 at 6:58 pm #41506
Hello, all. This is probably not worth asking, but it's more out of curiosity than anything. I'm running a very simple script to output users in a group. Obviously I can dump it to Excel and sort it very easily, but is there a way to sort it if I output to the screen?
Get-ADGroupMember -Identity group_name | select-object samaccountname
I apologize in advance if this is a ridiculous question I should be able to figure out on my own.
Loving this site!
RichJune 2, 2016 at 7:09 pm #41517
That's what the Sort-Object cmdlet does. For example:
Get-ADGroupMember -Identity group_name | Select-Object -Property SamAccountName | Sort-Object -Property SamAccountNameJune 2, 2016 at 7:11 pm #41519
I feel really dumb asking that now that I see how easy it was.
Thank you, Dave.June 2, 2016 at 7:14 pm #41521
No worries! 🙂 The *-Object commands are generally very useful. They give you a sort of query language that you can use on anything:
With those 5 commands, you can do some really powerful stuff. 🙂June 2, 2016 at 7:16 pm #41523
Sweet! That's rocking stuff.
Thanks, Dave!June 2, 2016 at 7:41 pm #41537
You can also pipe it to GridView, its a nice tool worth trying.
Get-ADGroupMember -Identity group_name | select-object samaccountname | Out-GridViewJune 2, 2016 at 8:55 pm #41548
As a way of teaching you to fish ;), I'd have done:
To discover Sort-Object.June 2, 2016 at 9:07 pm #41560
I appreciate all the feedback, everyone. I'm learning by leaps and bounds!
Thank you.June 3, 2016 at 2:41 pm #41650
Thanks for teaching us to fish... it's obvious, but in the heat of things it's sometimes easy to forget the simple way to find something.
You must be logged in to reply to this topic.