First create Full-Access-SendAS.csv :
Column1,Column2
Richard,Ronald
Ronald,Fred
This scripts gives the user Ronald Full Access and SendAs rights on the mailbox of user Richard, and the user Fred, Full Access and SendAs rights on the mailbox of user Ronald.
The option “-AutoMapping $false” prevents auto creation of the Richards mailbox in outlook of Ronald.
$List = Import-Csv C\Scripts\Full-Access-SendAS.csv
foreach ($Line in $List)
{
$UserMailbox = $Line.column1
$AccessUser = $Line.column2Write-Verbose $UserMailbox
write-Verbose $AccessUserfunction GiveFullAccess
{
Param ($UserMailbox2, $AccessUser2)
write-Verbose $UserMailbox2
write-Verbose $AccessUser2
Add-MailboxPermission -Identity $UserMailbox2 -User $AccessUser2 -AccessRights FullAccess -InheritanceType All -AutoMapping $false
}GiveFullAccess $UserMailbox $AccessUser
Write-Host -backgroundcolor green -ForegroundColor black “User “$AccessUser” now has full access on mailbox “$UserMailbox” !”function GiveSendAs
{
param ($UserMailbox2, $AccessUser2)
write-Verbose $UserMailbox2
write-Verbose $AccessUser2
Add-RecipientPermission $UserMailbox2 -AccessRights SendAs -Trustee $AccessUser2 -Confirm:$False
}GiveSendAs $UserMailbox $AccessUser
Write-Host -backgroundcolor green -ForegroundColor black “User “$AccessUser” now has SendAs rights on mailbox “$UserMailbox” !”}