Ok, without samples of your data, I just made up a couple of csvs to demonstrate how I would do this.
In the first one (one.csv) I put this:
Server,something,Permissions
ServerOne,foo,permissionsOne
ServerTwo,foo,permissionsTwo
ServerThree,foo,permissionsThree
In the second one (two.csv) I put this:
Server,something,Permissions
ServerOne,foo,permissionsOne
ServerTwo,foo,permissionsTwoAltered
ServerFour,foo,permissionsFour
So serverOne is in both and has the same permissions in both, serverTwo is in both but has different permissions in each one, serverThree is only in one.csv, and serverFour is only in two.csv.
Note that this is just a rough demo. There is nothing in it to handle case sensitivity for instance.
$hashOne = @{}
$csvOne = Import-CSV one.csv
$csvTwo = Import-CSV two.csv
$hashTwoOnly = @{}
$hashBothDifferent = @{}
$hashBothSame = @{}
foreach ($item in $csvOne)
{
$hashOne[$Item.Server] = $item.Permissions
}
forEach ($item in $csvTwo)
{
if ($hashOne.ContainsKey($item.Server))
{
if ($hashOne[$item.Server] -eq $item.Permissions)
{
$hashBothSame[$item.Server] = $item.Permissions
}else
{
$hashBothDifferent[$item.Server] = @{}
$hashBothDifferent[$item.Server]['FileOne'] = $hashOne[$item.Server]
$hashBothDifferent[$item.Server]['FileTwo'] = $item.Permissions
}
$hashOne.Remove($item.Server)
}else
{
$hashTwoOnly[$item.Server] = $item.Permissions
}
}
'The following servers were in both files and had identical permissions:'
foreach($name in $hashBothSame.Keys)
{
"$name -> $($hashBothSame[$name])"
}
''
''
'The following servers were only in file one:'
foreach($name in $hashOne.Keys)
{
"$name -> $($hashOne[$name])"
}
''
''
'The following servers were only in file two:'
foreach ($name in $hashTwoOnly.Keys)
{
"$name -> $($hashTwoOnly[$name])"
}
''
''
'The following were in both files but had different permissions listed:'
foreach ($name in $hashBothDifferent.Keys)
{
"$name ->"
"`tFile One -> $($hashBothDifferent[$name]['FileOne'])"
"`tFile Two -> $($hashBothDifferent[$name]['FileTwo'])"
}
The output from this is:
The following servers were in both files and had identical permissions:
ServerOne -> permissionsOne
The following servers were only in file one:
ServerThree -> permissionsThree
The following servers were only in file two:
ServerFour -> permissionsFour
The following were in both files but had different permissions listed:
ServerTwo ->
File One -> permissionsTwo
File Two -> permissionsTwoAltered