Hi,
We have a system that logs activities to a csv file and i am looking to read this CSV file and send stats out in the day.
I import the csv file using `$logTable = Import-Csv $logFile`
I would like to find the count of many different people, for example if i have 10 users, i can find how many activities they did by running
$user1 = ($logTable | Where-Object { ($_.date -EQ "06/01/2019") -and $_.user -EQ "user1" }).count $user2 = ($logTable | Where-Object { ($_.date -EQ "06/01/2019") -and $_.user -EQ "user2" }).count $user3 = ($logTable | Where-Object { ($_.date -EQ "06/01/2019") -and $_.user -EQ "user3" }).count ... ... $user10 = ($logTable | Where-Object { ($_.date -EQ "06/01/2019") -and $_.user -EQ "user10" }).count
I don’t feel this is the best way to be doing it though.
I need to collect the count for 30-40 variations
Dept 1
Total: 0 | 22
Service1: 0 | 6
Service2: 0 | 4
Service3: 0 | 0
Service4: 0 | 12
Breakdown By User:
User1: 0 | 0
User2: 0 | 15
User3: 0 | 0
The first number (before the pipe) is how many that day and the 2nd number is how many for the month so far
So you can see this would mean me duplicating the code above 40 times which would be messy.
I have the users and services stored in an array so was thinking there should be a way to loop through the arrays and save the count to a variable but not sure how to do that and also not sure if thats the correct way either as it would mean ending up with 40 variables.
What are you thoughts on handling such task?
Cheers,
jamie