powershell - 授予多个用户发送或代表发送权限?
问题描述
我想同时授予多个用户发送和/或代表发送权限。现在,我可以通过以下脚本一一授予权限。
我的 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"}
}
}
解决方案
推荐阅读
- android - android中的铃铛有什么用?
- javascript - Yii2:选择 dropDownList 上的所有选项,不带扩展名
- sql-server - SQL Server 2016 中 syscolpars 系统表的性能问题
- selenium - WebdriverWait Lambda 表达式
- openstack - openvswitch:如何打开网桥?
- java - 如何逐字合并字符串列表?
- node.js - 使用 mongoose 将值推送到数组中
- python - 如何从并行进程中运行的函数中检索值?
- node.js - 调用过程不像在 Node.js 的 For 循环中那样工作
- node.js - 请求未在承诺中发送