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