I am trying to set up an audit which requires that I dump all permissions into a CSV. I have script that reads a file of mailbox names and and am able to extract permissions. However, all of the permissions are listed in the CSV file and I am not able to distinguish which permission belongs to which file. Any guidance would be appreciated.
$list = Import-CSV "C:\powershell\MailPermissions.csv"
Foreach ($entry in $list) {
$user = $entry.comit
$tmp = get-mailbox -identity $user | Get-MailboxPermission | ?{-not ($_.User -match “NT AUTHORITY”) -and ($_.User -match “AMS\\X”) -or ($_.User -match “EUR\\X”)}
$Content+= $tmp
}
$Content | Export-CSV -path 'c:\powershell\MailPermissions_output.csv'