首页 > 解决方案 > 授予多个用户发送或代表发送权限?

问题描述

我想同时授予多个用户发送和/或代表发送权限。现在,我可以通过以下脚本一一授予权限。

我的 CSV 文件:

"DisplayName","PrimarySMTPAddress","SendAsPermissions","SendOnBehalfPermissions"
"DG01","DG01@contoso.com","CONTOSO\Ituser01;CONTOSO\Ituser02;CONTOSO\Ituser03","user01@contoso.com;user02@contoso.com"
"DG02","DG02@contoso.com","","user11@contoso.com;user42@contoso.com"
"DG03","DG03@contoso.com","CONTOSO\Ituser34",""

脚本 :

$importDLs = Import-Csv -Path C:\TEMP\delegate.csv

foreach ($importDL in $importDLs){

$importDL.SendAsPermissions
$importDL.SendOnBehalfPermissions


#Grant a user Send-On-Behalf to a distribution group so they can Send-on-behalf of the distribution group.
Set-DistributionGroup -Identity "$importDL.PrimarySMTPAddress" -GrantSendOnBehalfTo @{add="$importDL.SendOnBehalfPermissions"}

#Grant a user Send As permissions to a distribution group so they can send as the distribution group
Get-DistributionGroup "$importDL.PrimarySMTPAddress" | Add-ADPermission -User "$importDL.SendAsPermissions" -ExtendedRights "Send As"


}

最后更新 :

$importDLs = Import-Csv -Path C:\TEMP\delegate.csv

foreach ($importDL in $importDLs){

$importDLSendAs2 = $importDL.SendAsPermissions -split ";"
$importDLSendAsBehalf2 = $importDL.SendOnBehalfPermissions -split ";"
$dgmail=$importDL.PrimarySMTPAddress


foreach ($importDLSendAs in $importDLSendAs2) {
$domain,$importDLSendAsUser = $importDLSendAs.split('\')
$importDLSendAsUser

#Grant a user Send As permissions to a distribution group so they can send as the distribution group
Get-DistributionGroup "$dgmail" | Add-ADPermission -User "$importDLSendAsUser" -ExtendedRights "Send As"


}

foreach ($importDLSendAsBehalf in $importDLSendAsBehalf2) {

#Grant a user Send-On-Behalf to a distribution group so they can Send-on-behalf of the distribution group.
Set-DistributionGroup -Identity "$dgmail" -GrantSendOnBehalfTo @{add="$importDLSendAsBehalf"}


}



}

标签: powershell

解决方案


推荐阅读