Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
Active Directory
List users that are in following groups
Last Post 24 Oct 2011 04:25 AM by
serokles
. 0 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
serokles
New Member
Posts:9
24 Oct 2011 04:25 AM
I have managed to ham fist a decent answer to the following problem but I am absolutely certain that there is an easier or more elegant way to do this so here goes.
I have three AD groups and users are members of all, several or none of them depending. What I am trying to achieve is a count of all the unique users in these three groups.
I have been trying to use the official tools from Server 2008 R2 to do this and was able to get a result by running a get-adgroupmember for each group, exporting/appending to a text file, sorting and then piping to get-unique. This works but if I run a count against this it includes a count of the two separator lines at the begining of the text file. Not a real problem but annoying.
Is there a better way to do this? I was looking at a compare-object style approach but this only compares two objects.
The commands I ran so far:
First command ran for each group in question:
get-adgroupmember -Identity "Office 2007 SP2" | ft -Property samaccountname | out-file -Append users.txt
Then:
get-content users.txt | sort | get-unique > unique.txt
followed by a count of that text file. Longwinded but I can't seem to think of a way to do this without resorting to using Quest tools. Any help greatly appreciated.
You are not authorized to post a reply.
Using PowerShell
--General PowerShell
--Active Directory
--Exchange Server
--Lync Server
--SharePoint
--SQL Server
--System Center
--Non-Microsoft Products
--Books, Tools, and Videos
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
Active Directory
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2