What is the script for send on behalf permission?

Steel Contributor
We have send as script for Send As:
 
$access = "SendAs"
$mailbox = Get-Mailbox -Identity MYSHAREDMAILBOX
$identity = $mailbox.UserPrincipalName
$permissions = Get-MailboxPermission -identity $identity
 
$users = Import-Csv -Path "C:\path\members.csv" -Delimiter ";"
foreach($user in $users){
    try{
        $setPermissions = Add-MailboxPermission -Identity $identity -User $user -AccessRights $access
        Write-Host "Successfully added permissions for $user" -ForegroundColor Green
    }catch{
        Write-Host "Failed to add permissions for $user" -ForegroundColor Red
    }
}
 

What is the script for send on behalf permission?
2 Replies
There is -GrantSendOnBehalf parameter on the Set-Mailbox cmdlet you could check out.

https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/set-mailbox?view=exchange-ps

check if this helps,

 

$mailbox = Get-Mailbox -Identity MYSHAREDMAILBOX

$identity = $mailbox.UserPrincipalName

 

$users = Import-Csv -Path "C:\path\members.csv" -Delimiter ";"

foreach($user in $users){

    try{

        $setPermissions = Set-Mailbox -Identity $identity -GrantSendOnBehalf $user

        Write-Host "Successfully added permissions for $user" -ForegroundColor Green

    }catch{

        Write-Host "Failed to add permissions for $user" -ForegroundColor Red

    }

}

 

 

~Bart