[玩转系统] 如何将所有者添加到 Microsoft 365 组
作者:精品下载站 日期:2024-12-14 05:51:59 浏览:13 分类:玩电脑
如何将所有者添加到 Microsoft 365 组
Microsoft 365 组允许一组人员发送电子邮件并共享文件、日历和其他资源。所有者是 Microsoft 365 组的管理员,他们可以添加或删除成员以及更改组设置。在本文中,你将了解如何在 Microsoft Entra 管理中心和 PowerShell 中将所有者添加到 Microsoft 365 组。
先决条件
在开始将组所有者添加到 Microsoft 365 组之前,您需要创建 Microsoft 365 组。
Microsoft 365 组所有者
每个组织最多可以在 Microsoft 365 中创建 500,000 个组。下表显示了 Microsoft 365 组限制。
10 GB per subscribed user
Additional storage purchased (unlimited)Mailbox size50 GB
*只有1,000人可以一起访问群组对话。
注意:用户在 Outlook 中访问大型组中的日历和对话时可能会注意到延迟。
使用 Microsoft 365 组,您无需手动向每个成员分配权限。您可以将完全访问邮箱权限分配给 Microsoft 365 组,这将自动向成员授予相同的权限。
建议 Microsoft 365 组至少有两名所有者。这样,如果一个所有者不可用,另一位所有者可以对 Microsoft 365 组进行更改。
Microsoft 365 组所有者可以:
- 更改群组设置
- 添加或删除群组成员
- 删除群组
- 从共享收件箱中删除对话
- 重命名组
- 更新描述或图片
- 批准访客访问请求的邀请
将所有者添加到 Microsoft Entra ID 中的 Microsoft 365 组
要将所有者添加到 Microsoft Entra 管理中心的 Microsoft 365 组,请按照以下步骤操作:
- 登录 Microsoft Entra 管理中心
- 展开身份 > 组 > 所有组
- 从列表中单击Microsoft 365或安全组类型
注意:可以在 Microsoft Entra ID 和 Microsoft Graph PowerShell 中将所有者添加到 Microsoft 365 组和安全组。
- 点击所有者
- 点击添加所有者
- 选择用户
- 点击选择
您已成功将组所有者添加到 Microsoft 365 组。
注意:一个 Microsoft 365 组最多可以有 100 个所有者。在 Microsoft Entra 管理中心中,您最多可以选择 100 个用户并将他们添加为所有者。
如何将所有者添加到 Microsoft 365 组
您可以使用 PowerShell 将单个或多个所有者添加到 Microsoft 365 组。 Microsoft 365 组最多可以有 100 个所有者。
注意:来宾用户不能是群组的所有者,即使他们是群组的成员。
连接到 Microsoft Graph PowerShell
在开始之前,您必须安装 Microsoft Graph PowerShell 模块。以管理员身份启动 Windows PowerShell 并运行以下命令。
Install-Module Microsoft.Graph -Force
重要提示:在运行 cmdlet 或脚本之前,请务必安装最新的 Microsoft Graph PowerShell 模块版本,以防止出现错误和不正确的结果。
使用以下范围运行 Connect-MgGraph cmdlet 以通过 Microsoft Graph 进行身份验证。
Connect-MgGraph -Scopes "User.ReadWrite.All", "Group.ReadWrite.All", "GroupMember.ReadWrite.All"
现在一切就绪,您可以通过 MS Graph PowerShell 使用命令。
将所有者添加到 Microsoft 365 组
在我们的示例中,我们将向 Microsoft 365 组(管理团队)添加单个所有者。我们将使用 New-MgGroupOwner PowerShell cmdlet。
请参阅将所有者添加到 Microsoft 365 组的 PowerShell 语法。
New-MgGroupOwner -GroupId "Group Object Id" -DirectoryObjectId "Owner Object ID"
运行以下 PowerShell 命令,使用 MS Graph PowerShell 将所有者添加到 Microsoft 365 组。
New-MgGroupOwner -GroupId "031f52ea-cb97-40fc-ab0f-73598f3fc66d" -DirectoryObjectId "41377e9c-dc47-46c0-b4a5-1d5bbdcb5cc5"
将多个所有者添加到 Microsoft 365 组
要将多个所有者添加到 Microsoft 365 组,您还可以指定 UserPrincipalName。
- 输入您要添加的所有者的 UPN
- 输入组对象 ID
- 运行以下 PowerShell 脚本
$upns = @(
"[email protected]",
"[email protected]",
"[email protected]",
)
$GroupId = "031f52ea-cb97-40fc-ab0f-73598f3fc66d"
$Group = Get-MgGroup -GroupId $GroupId -ErrorAction SilentlyContinue
if ($Group) {
foreach ($upn in $upns) {
$User = Get-MgUser -Filter "userPrincipalName eq '$upn'"
if ($User) {
$UserId = $User.Id
$ExistingOwner = Get-MgGroupOwner -GroupId $GroupId
if ($ExistingOwner.Id -eq $UserId) {
Write-Host "User $($User.UserPrincipalName) already exists in the group." -ForegroundColor Yellow
}
else {
New-MgGroupOwner -GroupId $GroupId -DirectoryObjectId $UserId
Write-Host "User $($User.UserPrincipalName) added to the group." -ForegroundColor Green
}
}
else {
Write-Host "User $upn does not exist." -ForegroundColor Red
}
}
}
else {
Write-Host "Group $GroupId does not exist." -ForegroundColor Red
}
将批量所有者添加到 Microsoft 365 组
您可以使用 PowerShell 将所有所有者添加到单个 Microsoft 365 组。
注意:一个 Microsoft 365 组最多可以有 100 个所有者。当您将所有用户添加为所有者时,它只会按字母顺序添加前 100 个用户。
- 在第 编号 1 行中指定 Microsoft 365 组 ID
- 运行以下 PowerShell 脚本将用户作为所有者添加到单个 Microsoft 365 组
$GroupId = "031f52ea-cb97-40fc-ab0f-73598f3fc66d"
$Group = Get-MgGroup -GroupId $GroupId -ErrorAction SilentlyContinue
if ($Group) {
$Users = Get-MgUser -All
foreach ($User in $Users) {
$ExistingOwner = Get-MgGroupOwner -GroupId $GroupId
if ($ExistingOwner.Id -eq $User.Id) {
Write-Host "User $($User.UserPrincipalName) already exists as owner of the group." -ForegroundColor Yellow
}
else {
New-MgGroupOwner -GroupId $GroupId -DirectoryObjectId $User.Id
Write-Host "User $($User.UserPrincipalName) added as owner of the group." -ForegroundColor Green
}
}
}
else {
Write-Host "Group $GroupId does not exist." -ForegroundColor Red
}
如果所有者达到最大值 100,您将收到以下错误。
无法执行操作,因为“101”将超过前向链接“所有者”的最大配额计数“100”。
将特定部门的所有者添加到 Microsoft 365 组
在我们的示例中,我们希望将营销部门的所有用户添加到 Microsoft 365 组([email protected])。我们将使用 -Filter 参数和相等比较运算符 (-eq) 运算符,您可以在如何在 PowerShell 中使用比较运算符中阅读更多相关信息。
- 在第 1 行中键入 Microsoft 365 组 ID
- 运行以下 PowerShell 脚本
$GroupId = "031f52ea-cb97-40fc-ab0f-73598f3fc66d"
$Group = Get-MgGroup -GroupId $GroupId -ErrorAction SilentlyContinue
if ($Group) {
$Users = Get-MgUser -All -Filter "Department eq 'Marketing'"
foreach ($User in $Users) {
$ExistingOwner = Get-MgGroupOwner -GroupId $GroupId
if ($ExistingOwner.Id -eq $User.Id) {
Write-Host "User $($User.UserPrincipalName) already exists as owner of the group." -ForegroundColor Yellow
}
else {
New-MgGroupOwner -GroupId $GroupId -DirectoryObjectId $User.Id
Write-Host "User $($User.UserPrincipalName) added as owner of the group." -ForegroundColor Green
}
}
}
else {
Write-Host "Group $GroupId does not exist." -ForegroundColor Red
}
它将把营销部门的每个人添加为 Microsoft 365 组的所有者 ([email protected])。
从 CSV 将多个所有者添加到 Microsoft 365 组
要将多个所有者添加到单个 Microsoft 365 组,我们需要使用 CSV 文件。
创建一个包含两列的 CSV 文件:
- 打开Microsoft Excel
- 输入 UPN 作为第一列的标题
- 指定UserPrincipalName
- 输入 OwnerID 作为第二列的标题
- 指定所有者对象 ID
- 如果 (C:) 驱动器中还没有文件夹 temp,请创建该文件夹
- 将文件命名为 M365users.csv
- 保存类型为 CSV(逗号分隔 (*.csv)
- 点击保存
- 在第 1 行中指定CSV 文件路径
- 在第 2 行中键入 Microsoft 365 组 ID
- 运行以下 PowerShell 脚本
$CsvFilePath = "C:\temp\M365users.csv"
$GroupId = "031f52ea-cb97-40fc-ab0f-73598f3fc66d"
$Group = Get-MgGroup -GroupId $GroupId -ErrorAction SilentlyContinue
if ($Group) {
$CsvUsers = Import-Csv -Path $CsvFilePath
foreach ($CsvUser in $CsvUsers) {
$CsvUserID = $CsvUser.UserId
$User = Get-MgUser -Filter "Id eq '$CsvUserID'" -ErrorAction SilentlyContinue
if ($User) {
$UserId = $User.Id
$ExistingOwner = Get-MgGroupOwner -GroupId $GroupId
if ($ExistingOwner.Id -eq $UserId) {
Write-Host "User $($User.UserPrincipalName) already exists as owner of the group." -ForegroundColor Yellow
}
else {
New-MgGroupOwner -GroupId $GroupId -DirectoryObjectId $UserId
Write-Host "User $($User.UserPrincipalName) added as owner of the group." -ForegroundColor Green
}
}
else {
Write-Host "User $CsvUserID does not exist." -ForegroundColor Red
}
}
}
else {
Write-Host "Group $GroupId does not exist." -ForegroundColor Red
}
PowerShell 输出结果显示是否:
- Microsoft 365 组不存在或拼写错误
- 用户已作为 Microsoft 365 组的所有者存在
- 用户被添加为 Microsoft 365 组的所有者
- 用户不存在或拼写错误
从 CSV 将所有者添加到多个 Microsoft 365 组
您可以从 CSV 文件将所有者添加到多个 Microsoft 365 组。您需要创建一个由四列组成的 CSV 文件。前两列将包含 Microsoft 365 组的列表。第三列和第四列将包含您要添加为所有者的用户列表。
创建一个包含四列的 CSV 文件:
- 打开Microsoft Excel
- 输入 GroupName 作为第一列的标题
- 指定 Microsoft 365 组电子邮件
- 输入 GroupID 作为第二列的标题
- 指定 Microsoft 365组 ID
- 输入用户名作为第三列的标题
- 指定所有者UserPrincipalName
- 输入 OwnerID 作为第四列的标题
- 指定所有者对象 ID
请参阅下面的 CSV 文件示例。
- 如果 (C:) 驱动器中还没有文件夹 temp,请创建该文件夹
- 将文件命名为 M365owners.csv
- 保存类型为 CSV(逗号分隔 (*.csv)
- 点击保存
- 在第 1 行中指定CSV 文件路径
- 运行以下 PowerShell 脚本
$CsvFilePath = "C:\temp\M365owners.csv"
$Csv = Import-Csv $CsvFilePath
foreach ($row in $Csv) {
$GroupId = $Row.GroupID
$OwnerId = $Row.OwnerID
$Group = Get-MgGroup -GroupId $GroupId -ErrorAction SilentlyContinue
if ($Group) {
$ExistingOwner = Get-MgGroupOwner -GroupId $GroupId
if ($ExistingOwner.Id -eq $OwnerId) {
Write-Host "User $OwnerId already exists in the group." -ForegroundColor Yellow
}
else {
$User = Get-MgUser -Filter "Id eq '$OwnerId'" -ErrorAction SilentlyContinue
if ($User) {
New-MgGroupOwner -GroupId $GroupId -DirectoryObjectId $OwnerId
Write-Host "User $OwnerId added to the group." -ForegroundColor Green
}
else {
Write-Host "User $OwnerId doesn't exist" -ForegroundColor Red
}
}
}
else {
Write-Host "Group $GroupId does not exist." -ForegroundColor Red
}
}
PowerShell 输出结果显示是否:
- Microsoft 365 组不存在或拼写错误
- 用户已经是 Microsoft 365 组的所有者
- 用户已添加到 Microsoft 365 组
- 用户不存在或拼写错误
使用 CSV 将单一所有者添加到所有 Microsoft 365 组
要将所有者添加到多个 Microsoft 365 组,您需要创建 CSV 文件。
在我们的示例中,我们希望将用户(Amanda Hansen)添加为多个 Microsoft 365 组的所有者。
创建一个包含两列的 CSV 文件:
- 打开Microsoft Excel
- 输入组作为第一列的标题
- 指定 Microsoft 365 组主 SMTP 地址
- 输入 ObjectID 作为第二列的标题
- 指定 Microsoft 365 组对象 ID
- 如果 (C:) 驱动器中还没有文件夹 temp,请创建该文件夹
- 将文件命名为M365groups.csv
- 保存类型为 CSV(逗号分隔 (*.csv)
- 点击保存
- 在第 1 行中指定CSV 文件路径
- 在第 2 行中输入所有者对象 ID
- 运行以下 PowerShell 脚本
$CsvFilePath = "C:\temp\M365groups.csv"
$UserId = "41377e9c-dc47-46c0-b4a5-1d5bbdcb5cc5"
# Check if the user exists
$User = Get-MgUser -UserId $UserId -ErrorAction SilentlyContinue
if ($User) {
$CsvGroups = Import-Csv -Path $CsvFilePath
foreach ($row in $CsvGroups) {
$GroupId = $Row.ObjectID
$Group = Get-MgGroup -GroupId $GroupId -ErrorAction SilentlyContinue
if ($Group) {
$ExistingOwner = Get-MgGroupOwner -GroupId $GroupId
if ($ExistingOwner.Id -eq $UserId) {
Write-Host "User $UserId already exists in the group." -ForegroundColor Yellow
}
else {
New-MgGroupOwner -GroupId $GroupId -DirectoryObjectId $UserId
Write-Host "User $UserId added to the group." -ForegroundColor Green
}
}
else {
Write-Host "Group $GroupId does not exist." -ForegroundColor Red
}
}
}
else {
Write-Host "User $UserId does not exist." -ForegroundColor Red
}
就是这样!
阅读更多内容:如何使用 PowerShell 将所有者添加到分发组 »
结论
您了解了如何在 Microsoft Entra 管理中心和使用 PowerShell 将所有者添加到 Microsoft 365 组。您可以将单个、多个和所有用户作为所有者添加到 Microsoft 365 组。请记住,每个 Microsoft 365 组最多只能添加 100 个所有者。
您喜欢这篇文章吗?您可能还喜欢如何在 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