How to count how many users a group has, including nested groups

I must admit that i was searching for one hour how to see how many members a given group has, so something like a count of members but also including nested groups. It’s a sweet PowerShell command for you guys making reports like i do.
Well here it is:

Get-QADGroup group_nam* -SizeLimit 0 | Select-Object Name,@{n='MemberCount';e={ (Get-QADGroupMember -Indirect -SizeLimit 0 $_ | Measure-Object).Count}}

The * (star) before -SizeLimit is telling powershell to apply the command for all groups begging with “group_nam”, so the query is valid for “group_name” but also for “group_name_in_another_location”

By removing the -Indirect statement, you get only the direct members, excluding nested ones (members of other groups, inside given group)

Advertisements
About

Victor an End User Computing Consultant. You find him most of the time on Twitter (@01004753) but also on LinkedIn evangelizing new technologies and processes that can change in good, the world we live in. Victor has expertise in Server & Client Virtualization, Client Management, GPU Virtualization, HyperConvergence and Enterprise Security

Posted in HowTo, PowerShell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Follow Victor Homocea on WordPress.com
My Gravatar

Trafictube.ro

cu camera pe bord

Thincomputing.net

by Michel Roth on the VDI, Desktop Virtualizaion, Application Virtualization, UEM aspects of End User Computing and Product Management

Ingmar Verheij

About Citrix, Remote Desktop, Performance, Workspace, Monitoring and more...

Carl Stalhood

Filling gaps in EUC vendor documentation

Archy.net

Don't Follow the Trend

Victor Homocea

blog.ogs.ro

Ray Heffer

Double VCDX #122 | Cloud Architect

Elvis Apostol

Calatorind prin lumi indepartate, pictez in cuvinte, lacrimi de culori.

%d bloggers like this: