Link to home
Start Free TrialLog in
Avatar of MilesLogan
MilesLoganFlag for United States of America

asked on

output total number of users in AD groups.

Hi ALL

I am trying to get the total number of group members to output to a file and cant figure it out .
I just need a simple file .. txt or .csv that will show the total group members of groups that are in groups.txt

Below works but I want the output to a file .
If ([array]$users = (gc groups.txt | Get-ADGroupMember))
{
      "Number of users in groups: $($users.count)"
}


I tried below but I cant get it to just output a one liner with the total count.

$Users | Select * | Export-Csv Groupcount_$((Get-Date -Format MM-dd-yyyy)).csv -NoTypeInformation
ASKER CERTIFIED SOLUTION
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MilesLogan

ASKER

Thank you Raheman