Created
June 23, 2017 15:58
-
-
Save kevinblumenfeld/7466f8190ee674fee5d7bf5d1cf3e2b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$OutFile = ".\365PermissionExport.csv" | |
"DisplayName" + "," + "Alias" + "," + "PrimarySMTP" + "," + "FullAccess" + "," + "SendAs" + "," + "SendonBehalf" | Out-File $OutFile -Force -encoding ascii | |
$Mailboxes = import-csv .\someupns.csv | |
# $Mailboxes = Get-Mailbox -ResultSize:Unlimited | |
ForEach ($Mailbox in $Mailboxes) | |
{ | |
$SendAs = Get-RecipientPermission $Mailbox.PrimarySmtpAddress | ? {$_.AccessRights -match "SendAs" -and $_.Trustee -ne "NT AUTHORITY\SELF"} | % {$_.trustee} | |
$FullAccess = Get-MailboxPermission $Mailbox.PrimarySmtpAddress | ? {$_.AccessRights -eq "FullAccess" -and !$_.IsInherited} | % {$_.User} | |
$sendbehalf=Get-Mailbox $Mailbox.PrimarySmtpAddress | select-object -ExpandProperty GrantSendOnBehalfTo | |
if (!$SendAs -and !$FullAccess -and !$sendbehalf){continue} | |
$Mailbox.DisplayName + "," + $Mailbox.Alias + "," + $Mailbox.primarysmtpaddress + "," + $FullAccess + "," + $SendAs + "," + $sendbehalf | Out-File $OutFile -Append -encoding ascii | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment