Home

What is the script for send on behalf permission?

%3CLINGO-SUB%20id%3D%22lingo-sub-452936%22%20slang%3D%22en-US%22%3EWhat%20is%20the%20script%20for%20send%20on%20behalf%20permission%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-452936%22%20slang%3D%22en-US%22%3EWe%20have%20send%20as%20script%20for%20Send%20As%3A%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%24access%20%3D%20%22SendAs%22%3CBR%20%2F%3E%24mailbox%20%3D%20Get-Mailbox%20-Identity%20MYSHAREDMAILBOX%3CBR%20%2F%3E%24identity%20%3D%20%24mailbox.UserPrincipalName%3CBR%20%2F%3E%24permissions%20%3D%20Get-MailboxPermission%20-identity%20%24identity%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%24users%20%3D%20Import-Csv%20-Path%20%22C%3A%5Cpath%5Cmembers.csv%22%20-Delimiter%20%22%3B%22%3CBR%20%2F%3Eforeach(%24user%20in%20%24users)%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20try%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%24setPermissions%20%3D%20Add-MailboxPermission%20-Identity%20%24identity%20-User%20%24user%20-AccessRights%20%24access%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Write-Host%20%22Successfully%20added%20permissions%20for%20%24user%22%20-ForegroundColor%20Green%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7Dcatch%7B%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Write-Host%20%22Failed%20to%20add%20permissions%20for%20%24user%22%20-ForegroundColor%20Red%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EWhat%20is%20the%20script%20for%20send%20on%20behalf%20permission%3F%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-452936%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-453216%22%20slang%3D%22en-US%22%3ERe%3A%20What%20is%20the%20script%20for%20send%20on%20behalf%20permission%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-453216%22%20slang%3D%22en-US%22%3EThere%20is%20-GrantSendOnBehalf%20parameter%20on%20the%20Set-Mailbox%20cmdlet%20you%20could%20check%20out.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fexchange%2Fmailboxes%2Fset-mailbox%3Fview%3Dexchange-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fmodule%2Fexchange%2Fmailboxes%2Fset-mailbox%3Fview%3Dexchange-ps%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-615817%22%20slang%3D%22en-US%22%3ERe%3A%20What%20is%20the%20script%20for%20send%20on%20behalf%20permission%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-615817%22%20slang%3D%22en-US%22%3E%3CP%3Echeck%20if%20this%20helps%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E%24mailbox%20%3D%20Get-Mailbox%20-Identity%20MYSHAREDMAILBOX%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24identity%20%3D%20%24mailbox.UserPrincipalName%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%26nbsp%3B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%24users%20%3D%20Import-Csv%20-Path%20%22C%3A%5Cpath%5Cmembers.csv%22%20-Delimiter%20%22%3B%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3Eforeach(%24user%20in%20%24users)%7B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20try%7B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%24setPermissions%20%3D%20Set-Mailbox%20-Identity%20%24identity%20-GrantSendOnBehalf%20%24user%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Write-Host%20%22Successfully%20added%20permissions%20for%20%24user%22%20-ForegroundColor%20Green%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7Dcatch%7B%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Write-Host%20%22Failed%20to%20add%20permissions%20for%20%24user%22%20-ForegroundColor%20Red%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CEM%3E%7D%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CEM%3E~Bart%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Marvin Oco
Super 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

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
35 Replies
Extentions Synchronization
ChirmyRam in Discussions on
3 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies