# Exchange 2013 – GrantSendOnBehalfTo nadpisuje wcześniejsze uprawnienia SendOnBehalf dla skrzynki pocztowej

Zmiana ustawienia Send On Behalf w Exchange 2010 / Exchange 2013 lub Exchange 2016 jest czynnością, którą można wykonać w prosty sposób z ECP lub…

blog

22 Jan 2016 pl

![Exchange 2013 – GrantSendOnBehalfTo nadpisuje wcześniejsze uprawnienia SendOnBehalf dla skrzynki pocztowej](/wp-content/uploads/2016/02/MicrosoftExchange.png)

Zmiana ustawienia **Send On Behalf **w **Exchange 2010** / **Exchange 2013** lub **Exchange 2016** jest czynnością, którą można wykonać w prosty sposób z ECP lub ECM. Niestety przy próbie zmian uprawnień **Send On Behalf **z poziomu **PowerShell **czynność ta staje się trochę bardziej ryzykowna.Większość osób przy pierwszej możliwej sposobności użyje komendy

```plain
Set-Mailbox  -GrantSendOnBehalf
```

W założeniu prosta komenda powershellowa ma niestety jedną wadę. Nadpisuje pole które ustawia, w tym przypadku nadpisując ustawienia **GrantSendOnBehalf**. O ile w pierwszej chwili nie jest to problem, bo zazwyczaj pole to jest puste. O tyle przy większych środowiskach Exchange, gdzie takie uprawnienia są już nadane wcześniej może to powodować duże problemy przy próbie zmiany pola **GrantSendOnBehalf, **a nadpisanie go najczęściej skutkuje usunięciem dużej grupy osób.Na szczęście jest prosta metoda by nie nadpisywać tych ustawień. Poniżej możecie znaleźć kilka komend, które potrafią ułatwić życie administratora Exchange.

```plain
function Add-DistributionListGrantSendOnBehalfTo { Param($newTrustee, $targetDistributionGroup)
    Set-DistributionGroup $targetDistributionGroup -GrantSendOnBehalfTo @{add=$newTrustee}
}
function Remove-DistributionListGrantSendOnBehalfTo { Param($oldTrustee, $targetDistributionGroup)
    Set-DistributionGroup $targetDistributionGroup -GrantSendOnBehalfTo @{remove=$oldTrustee}
}
function Replace-DistributionListGrantSendOnBehalfTo { Param($oldTrustee, $newTrustee, $targetDistributionGroup)
    Set-DistributionGroup $targetDistributionGroup -GrantSendOnBehalfTo @{add=$newTrustee}
    Set-DistributionGroup $targetDistributionGroup -GrantSendOnBehalfTo @{remove=$oldTrustee}
}
function Remove-MailboxGrantSendOnBehalfTo { Param($oldTrustee, $targetMailbox)
    Set-Mailbox $targetMailbox -GrantSendOnBehalfTo @{remove=$oldTrustee}
}
function Add-MailboxGrantSendOnBehalfTo { Param($newTrustee, $targetMailbox)
    Set-Mailbox $targetMailbox -GrantSendOnBehalfTo @{add=$newTrustee}
}
function Replace-MailboxGrantSendOnBehalfTo { Param($oldTrustee, $newTrustee, $targetMailbox)
    Set-Mailbox $targetMailbox -GrantSendOnBehalfTo @{remove=$oldTrustee}
    Set-Mailbox $targetMailbox -GrantSendOnBehalfTo @{add=$newTrustee}
}
```

**Podstawowe użycie** komend Exchange PowerShell opisanych powyżej:

```plain
Add-MailboxGrantSendOnBehalfTo -NewTrustee  -TargetMailbox

Replace-MailboxGrantSendOnBehalfTo -NewTrustee  -OldTrustee  -TargetMailbox

Remove-MailboxGrantSendOnBehalfTo -OldTrustee  -TargetMailbox
```

## Powiązane projekty

Projekty powiązane z tagami, kategoriami i treścią tego wpisu.

[Wszystkie projekty](/projekty/)

Trwa dopasowywanie projektów...

[Powrót do bloga](/blog/)

## Powiązane wpisy

- [Check an API write after a PowerShell timeout](/blog/verify-uncertain-api-outcomes-powershell/)
- [Compose PDF reports and automate page workflows with PSWriteOffice](/blog/automate-pdf-reports-and-page-workflows-pswriteoffice/)
- [ImagePlayground: image automation that stays in PowerShell](/blog/imageplayground-powershell-image-automation/)

<!-- PowerForge markdown artifact sha256:B68B14D26389AE9C922758044F3823DFA2DB02DB8E3D1DCF8FB99640A2EFC70B -->
