Forum Discussion

Marvin Oco's avatar
Marvin Oco
Iron Contributor
Apr 15, 2019

What is the script for send on behalf permission?

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

  • bartthemustang's avatar
    bartthemustang
    Copper Contributor

    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

  • dotpwsh's avatar
    dotpwsh
    Copper Contributor
    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

Resources