[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 659
  • Last Modified:

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
0
MilesLogan
Asked:
MilesLogan
1 Solution
 
Raheman M. AbdulCommented:
If ([array]$users = (gc groups.txt | Get-ADGroupMember))
{
      "Number of users in groups: $($users.count)" | out-file c:\temp\UserCount.txt
}
0
 
MilesLoganAuthor Commented:
Thank you Raheman
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now