Install ADFS on Azure VM step by step

Get send on behalf access report well formated.

This Script will generate report of  "Send on behalf" permissions, if there are more then one user has permissions, the same will be added in a new line.

Sample Output.

IDENTITY User
Test1 testuser1@xyz.com
Test1 testuser2@xyz.com
Test2 testuser1@xyz.com
Test3 testuser1@xyz.com
Test3 testuser4@xyz.com
Test6 testuser1@xyz.com

this report can be used in future to revert the permissions back.

$AllMailbox = Get-mailbox -resultsize unlimited

$Report=@()

write-host "Formating sob permission in required report format..."
foreach ($mbx in $allMailbox)

 {
  if (!$mbx.GrantSendOnBehalfto)
   {
    write-host "No One has Send On Behalf Rights on:" $mbx.alias
    $Reportdata = New-Object –TypeName PSObject    
    $reportData | Add-Member –MemberType NoteProperty –Name IDENTITY –Value $mbx.Alias;
    $reportData | Add-Member –MemberType NoteProperty –Name User –Value "Null";
    $reportData
    
    $Report += $reportdata
   }
  Else
   { 
    
    Write-host "SOB permission enery found" -f Green
    foreach ($entry in $mbx.Grantsendonbehalfto)
    { 
     $Reportdata = New-Object –TypeName PSObject
     $reportData | Add-Member –MemberType NoteProperty –Name IDENTITY –Value $mbx.Alias;
     $reportData | Add-Member –MemberType NoteProperty –Name User -Value $entry;
     $reportData
     $Report += $reportdata
    }
   }
 }
 $ReportName = "SendonBehalfto-Backup-" + $(get-date -Format MM-dd-yyyy) + ".Csv"
 $report | Export-csv $ReportName -notype

Comments