[玩转系统] 如何将通讯组列表转换为安全组
作者:精品下载站 日期:2024-12-14 05:51:41 浏览:13 分类:玩电脑
如何将通讯组列表转换为安全组
在 Microsoft 365 中,您无法将通讯组列表转换为启用邮件的安全组。使用 PowerShell 脚本,可以将相同的成员从通讯组列表复制到安全组。在本文中,您将了解如何将通讯组列表转换为启用邮件的安全组,反之亦然。
分发与安全组
在我们将通讯组列表转换为 Microsoft 365 中启用邮件的安全组之前,了解它们的差异非常重要。
- 通讯组用于向一组人发送电子邮件通知。
- 启用邮件的安全组用于向所有组成员发送电子邮件并授予他们对 SharePoint 等资源的访问权限。
我们可以使用通讯组列表和启用邮件的安全组向每个成员发送电子邮件通知。
这些组之间的主要区别在于我们只能使用安全组来分配权限。这意味着我们不能使用通讯组列表组来分配权限。通讯组未启用安全性,这意味着它们不能列在自主访问控制列表 (DACL) 中。
下表显示通讯组列表和启用邮件的安全组之间的差异。
Assign permissions是的
Send an email to the group是的
如果您为安全组分配权限,则所有组成员都会自动继承分配给该组的权限。
- 当您将新用户添加到安全组时,它将自动继承分配给安全组的权限。
- 从安全组中删除用户将自动删除分配给该组成员的权限。
连接到 Exchange Online PowerShell
为了能够运行 PowerShell 命令,您必须连接到 Exchange Online PowerShell。以管理员身份打开 Windows PowerShell,运行以下 cmdlet,然后使用管理员凭据登录。
Connect-ExchangeOnline
将成员从通讯组列表复制到安全组
Exchange Online 中没有将现有通讯组列表转换为启用邮件的安全组的选项。因此,我们需要使用PowerShell将通讯组列表中的所有成员复制到现有的安全组中。
我们将向您展示将通讯组列表复制到安全组中的步骤:
- 创建新的启用邮件的安全组
首先,您需要拥有一个现有的安全组或创建一个新的安全组。在我们的示例中,我们将创建一个新的启用邮件的安全组([email protected])。
运行以下 Powershell 示例来创建新的安全组。
New-DistributionGroup -Name "Finance UK" -PrimarySmtpAddress "[email protected]" -ManagedBy "[email protected]" -Type Security
- 将现有通讯组列表中的所有成员复制到新安全组
下一步是将通讯组列表的成员转换为新的启用邮件的安全组。
请参阅下面的 PowerShell 示例语法。
$Members = Get-DistributionGroupMember -ResultSize Unlimited -Id "Distribution Group"
foreach ($Member in $Members) {
Add-DistributionGroupMember -Identity "Security Group" -Member $Member.name
}
我们希望将(英国销售)通讯组列表的相同成员复制到启用邮件的安全组(英国财务)。
- 在第 1 行中指定通讯组列表主 SMTP 地址
- 在第 3 行中指定启用邮件的安全组主 SMTP 地址
- 运行以下 PowerShell 脚本
注意:要将成员从启用邮件的安全组复制到通讯组列表,您需要在 PowerShell 脚本中反转组的顺序。
$Members = Get-DistributionGroupMember -ResultSize Unlimited -Id "[email protected]"
foreach ($Member in $Members) {
Add-DistributionGroupMember -Identity "[email protected]" -Member $Member.name -BypassSecurityGroupManagerCheck
}
您已将所有通讯组列表成员转移到启用邮件的安全组。
- 最后一步是删除通讯组
运行以下 PowerShell 命令来删除通讯组。
Remove-DistributionGroup "[email protected]" -BypassSecurityGroupManagerCheck -Confirm:$false
如果您想要使用 PowerShell 自动将通讯组列表转换为启用邮件的安全组,请选择下一个选项。
将通讯组列表所有者和成员转换为安全组
要将所有所有者和成员从通讯组列表复制到新创建的安全组,我们需要使用不同的方法。
我们创建了一个 PowerShell 脚本,它将:
- 创建新的启用邮件的安全组
- 将所有者和成员从现有通讯组列表复制到新创建的安全组
- 删除原来的通讯组列表
注意:您无法使用相同的主 SMTP 地址创建另一个组。
以下脚本将自动创建一个与通讯组同名的新安全组。但我们需要在新创建的安全组的主SMTP地址末尾临时添加-New。最后,该脚本将从启用邮件的安全组的主 SMTP 地址中删除原始通讯组和-New。
- 在行号 1 中指定管理员 UPN
- 在第 2 行中指定通讯组列表组主 SMTP 地址
- 运行以下 PowerShell 脚本
注意:要将启用邮件的安全组转换为通讯组列表,您需要删除以下 PowerShell 脚本中第 25 行的-Type Security。
$Admin = "[email protected]"
$DistributionGroup = "[email protected]"
# Connect to Exchange Online PowerShell
Connect-ExchangeOnline
# Get distribition group
$DG = Get-DistributionGroup -ResultSize Unlimited -Identity $DistributionGroup -ErrorAction SilentlyContinue
# Check if group exist
if ($DG -eq $null) {
Write-Host "The distribution group '$DistributionGroup' does not exist." -ForegroundColor Red
}
else {
# Get all the members of the distribution group
$Members = Get-DistributionGroupMember -ResultSize Unlimited -Identity $DistributionGroup
$Owners = $DG.ManagedBy
# Split the distribution group address
$GroupName = $DG.DisplayName
$SplittedAddress = $DG.PrimarySmtpAddress -split "@"
$PrimarySmtpAddressNew = "$($SplittedAddress[0])-New@$($SplittedAddress[1])"
# Create a new security group with a name based on the distribution group
$null = New-DistributionGroup -Name $GroupName -PrimarySmtpAddress $PrimarySmtpAddressNew -Type Security
Write-Host "Created NEW security group $GroupName ($PrimarySmtpAddressNew)." -ForegroundColor Green
# Loop through each owner of the original group
Write-Host "Adding owners to security group $GroupName ($PrimarySmtpAddressNew)." -ForegroundColor Green
foreach ($Owner in $Owners) {
# Add the owner to the new security group
Set-DistributionGroup -Identity "$PrimarySmtpAddressNew" -ManagedBy @{Add = $Owners } -BypassSecurityGroupManagerCheck -ErrorAction Stop
}
# Loop through each member of the original group
Write-Host "Adding members to security group $GroupName ($PrimarySmtpAddressNew)." -ForegroundColor Green
foreach ($Member in $Members) {
# Add the member to the new security group
Add-DistributionGroupMember -Identity "$PrimarySmtpAddressNew" -Member $Member.Identity -BypassSecurityGroupManagerCheck -ErrorAction SilentlyContinue
}
# Remove admin from new security group
Set-DistributionGroup -Identity "$PrimarySmtpAddressNew" -ManagedBy @{Remove = $Admin } -BypassSecurityGroupManagerCheck -ErrorAction Stop
Write-Host "Removed admin $($Admin) from security group $GroupName ($PrimarySmtpAddressNew)." -ForegroundColor Green
# Remove the original distribution group
Remove-DistributionGroup -Identity "$DistributionGroup" -BypassSecurityGroupManagerCheck -Confirm:$false
Write-Host "Removed Distribution Group $($DistributionGroup)." -ForegroundColor Green
# Remove the -New from the security group
Set-Distributiongroup -Identity $PrimarySmtpAddressNew -PrimarySmtpAddress $DistributionGroup
Write-Host "Updated security group primary SMTP address to $($DistributionGroup)." -ForegroundColor Green
}
PowerShell 输出结果显示通讯组列表的成员和所有者已转移到新安全组。它删除了原始通讯组列表,新安全组的主 SMTP 地址现在与原始通讯组列表相同。
Created NEW security group Sales UK ([email protected]).
Adding owners to security group Sales UK ([email protected]).
Adding members to security group Sales UK ([email protected]).
Removed admin [email protected] from security group Sales UK ([email protected]).
Removed Distribution Group [email protected].
Updated security group primary SMTP address to [email protected].
就是这样!
阅读更多:如何分配完全访问邮箱权限 »
结论
您学习了如何将通讯组转换为安全组。首先,PowerShell 脚本将创建一个新的启用邮件的安全组。接下来,它将把通讯组列表的所有者和成员转换为新创建的启用邮件的安全组。截至最后,它将删除通讯组列表。
您喜欢这篇文章吗?您可能还喜欢使用 PowerShell 管理用户邮箱。不要忘记关注我们并分享这篇文章。
猜你还喜欢
- 03-30 [玩转系统] 如何用批处理实现关机,注销,重启和锁定计算机
- 02-14 [系统故障] Win10下报错:该文件没有与之关联的应用来执行该操作
- 01-07 [系统问题] Win10--解决锁屏后会断网的问题
- 01-02 [系统技巧] Windows系统如何关闭防火墙保姆式教程,超详细
- 12-15 [玩转系统] 如何在 Windows 10 和 11 上允许多个 RDP 会话
- 12-15 [玩转系统] 查找 Exchange/Microsoft 365 中不活动(未使用)的通讯组列表
- 12-15 [玩转系统] 如何在 Windows 上安装远程服务器管理工具 (RSAT)
- 12-15 [玩转系统] 如何在 Windows 上重置组策略设置
- 12-15 [玩转系统] 如何获取计算机上的本地管理员列表?
- 12-15 [玩转系统] 在 Visual Studio Code 中连接到 MS SQL Server 数据库
- 12-15 [玩转系统] 如何降级 Windows Server 版本或许可证
- 12-15 [玩转系统] 如何允许非管理员用户在 Windows 中启动/停止服务
取消回复欢迎 你 发表评论:
- 精品推荐!
-
- 最新文章
- 热门文章
- 热评文章
[影视] 黑道中人 Alto Knights(2025)剧情 犯罪 历史 电影
[古装剧] [七侠五义][全75集][WEB-MP4/76G][国语无字][1080P][焦恩俊经典]
[实用软件] 虚拟手机号 电话 验证码 注册
[电视剧] 安眠书店/你 第五季 You Season 5 (2025) 【全10集】
[电视剧] 棋士(2025) 4K 1080P【全22集】悬疑 犯罪 王宝强 陈明昊
[软件合集] 25年6月5日 精选软件22个
[软件合集] 25年6月4日 精选软件36个
[短剧] 2025年06月04日 精选+付费短剧推荐33部
[短剧] 2025年06月03日 精选+付费短剧推荐25部
[软件合集] 25年6月3日 精选软件44个
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电视剧] 欢乐颂.5部全 (2016-2024)
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[影视] 【稀有资源】香港老片 艺坛照妖镜之96应召名册 (1996)
[剧集] 神经风云(2023)(完结).4K
[剧集] [BT] [TVB] [黑夜彩虹(2003)] [全21集] [粤语中字] [TV-RMVB]
[实用软件] 虚拟手机号 电话 验证码 注册
[资源] B站充电视频合集,包含多位重量级up主,全是大佬真金白银买来的~【99GB】
[影视] 内地绝版高清录像带 [mpg]
[书籍] 古今奇书禁书三教九流资料大合集 猎奇必备珍藏资源PDF版 1.14G
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电影] 美国队长4 4K原盘REMUX 杜比视界 内封简繁英双语字幕 49G
[电影] 死神来了(1-6)大合集!
[软件合集] 25年05月13日 精选软件16个
[精品软件] 25年05月15日 精选软件18个
[绝版资源] 南与北 第1-2季 合集 North and South (1985) /美国/豆瓣: 8.8[1080P][中文字幕]
[软件] 25年05月14日 精选软件57个
[短剧] 2025年05月14日 精选+付费短剧推荐39部
[短剧] 2025年05月15日 精选+付费短剧推荐36部
- 最新评论
-
- 热门tag