Export FullAccess & SendAs permissions for Shared Mailboxes…

Posted by in Exchange, PowerShell

Ever been asked to get an export of all the assigned permissions to a group of mailboxes? With this script you’ll be able to export the Full Access and & Send As permissions for whatever group of mailboxes you wish. This script works on Exchange 2007 but there’s no reason why it won’t work for Exchange 2010 either.

You can customise the $Mailboxes query to gather whatever mailboxes you wish to export the details for. This is just a Get-Mailbox query. The export will be in the form of a txt file but the results will be delimited with a ^ symbol. Just import this to Excel to make it pretty.

$OutFile = "C:\Temp\PermissionExport.txt"
"DisplayName" + "^" + "Alias" + "^" + "Full Access" + "^" + "Send As" | Out-File $OutFile -Force
$Mailboxes = Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize:Unlimited | Select Identity, Alias, DisplayName, DistinguishedName
ForEach ($Mailbox in $Mailboxes) {
	$SendAs = Get-ADPermission $Mailbox.DistinguishedName | ? {$_.ExtendedRights -like "Send-As" -and $_.User -notlike "NT AUTHORITY\SELF" -and !$_.IsInherited} | % {$_.User}
	$FullAccess = Get-MailboxPermission $Mailbox.Identity | ? {$_.AccessRights -eq "FullAccess" -and !$_.IsInherited} | % {$_.User}
	$Mailbox.DisplayName + "^" + $Mailbox.Alias + "^" + $FullAccess + "^" + $SendAs | Out-File $OutFile -Append

Ta ta for now.