# Created By Alberto Igbinedion
<# Addding Send As Permission Allows user to be able to send on behalf 

Add-ADPermission -Identity 'Outlook Feedback' -User 'igbina' -AccessRights 'ExtendedRight' -ExtendedRights 'send as'
#>

#.\GrantUserMBSendAsPermissing.ps1 
# GrantSendAs -identity "$identity" -User "$users"
# GrantSendAs


Function GrantSendAs {


Param (


[String]$identity,
[String]$userList,
[String]$user

)


$userList = Get-content "C:\Scripts\Input\Users.txt"
$Identity = Read-Host "Enter the FullName of the Mailbox To Add AccessRight"
$user = read-Host "Enter User To Grant Access"
$AccessRights = read-host "Enter the access Rights"

Add-ADPermission -Identity (Get-Mailbox $Identity).DistinguishedName -User $User -ExtendedRights $AccessRights |


%{
# Check Send As Permission has been applied to mailbox
Get-ADPermission -Identity (Get-Mailbox $Identity).DistinguishedName | Where-Object {$_.extendedrights -like "*send*"}

}


}


# Remove MAilbox Permissions
# $users = Get-content "C:\Scripts\Input\Users.txt"
# Remove-ADPermission -Identity "Outlook Feedback" -User "$users" -ExtendedRights 'send as' 
