Hi Folks,
So I have a user access report and a key file (.CSVs) that I’m trying to compare. Here is an example of the data:
users.csv
Username,jobtitle,permission1,permission2,permission3,permission4,permission5
bill,wizard,0,0,0,1,3
jack,archer,1,0,0,2,4
barb,healer,0,1,1,0,0
key.csv
jobtitle,permission1,permission2,permission3,permission4,permission5
wizard,0,0,0,0,3
archer,1,0,0,2,4
healer,1,1,1,1,1
The output needs to look like the following. I’m trying to get a simplified report that associates a user’s permissions to their title while also showing “wildcard” permissions:
Username,jobtitle,permission1,permission2,permission3,permission4,permission5,titlematch
bill,wizard,1,wizard
jack,archer,archer
barb,healer,0,0,0,healer
In the actual data there are 20,000 users, 500 titles, and 120 permissions
Here is what I have so far. It only outputs exact matches which isn’t really helpful. I’ve been wondering if I’m even close on this.
Any help would be greatly appreciated. Cheers,
$Data = import-csv "C:\users.csv" $Key = import-csv "C:\key.csv" $permissions = permission1,permission2,permission3,permission4,permission5 Foreach ($D in $Data){ foreach ($K in $Key){ if($D."JobTitle" -eq $K."JobTitle"){ Compare-Object -ReferenceObject $D -DifferenceObject $K -Property $permissions -IncludeEqual -ExcludeDifferent -PassThru | Select-Object * -ExcludeProperty SideIndicator | Export-Csv "C:\results.csv" -Append -notypeinformation } } }