SharePoint Online:允许成员使用 PowerShell 编辑组成员身份
要求:配置 SharePoint Online 组以管理组成员的成员身份。
如何让群组成员管理群组?
Microsoft SharePoint Online Groups 提供了一种管理用户及其成员身份的简单方法。作为管理员,您可以添加或删除成员或委派权限,以便现有群组成员可以邀请其他人加入该群组。本指南将向您展示如何设置谁可以管理 SharePoint Online 中的组成员身份。
请按照以下步骤更改 SharePoint Online 中组的组设置。
- 转到“网站设置”>> 点击“人员和群组”链接
- 从左侧导航中选择您想要更改组设置的组。
- 在群组页面中,单击工具栏中的“设置>>群组设置”。
在“组设置”下,为“谁可以编辑组的成员资格?”设置“组成员”选项。
- 单击“确定”保存更改。
通过这些更改,群组成员将能够在群组中添加或删除其他成员。对于希望允许组成员管理组成员身份而不需要对网站集进行管理访问的组织来说,这可能是一个有用的功能。
PowerShell 更新组设置以允许成员管理组:
让我们探讨如何允许成员使用 PowerShell 编辑组成员身份。以下是如何自动执行上述组设置:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Parameters
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"
#Setup Credentials to connect
$Cred = Get-Credential
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
#Get All Groups of the Site
$SiteGroups = $Ctx.web.SiteGroups
$Ctx.Load($SiteGroups)
$Ctx.ExecuteQuery()
#Iterate through each Group - Exclude SharePoint Online System Groups!
ForEach($Group in $SiteGroups | Where {$_.OwnerTitle -ne "System Account"})
{
#Update Group Settings: Who can edit the membership of the group? to Grop Members
$Group.AllowMembersEditMembership = $True
$Group.Update()
$Ctx.ExecuteQuery()
Write-host -f Green "Group Settings for '$($Group.Title)' Updated to Edit Membership by Group Members!"
}
}
Catch {
write-host -f Red "Error Updating Group Settings!" $_.Exception.Message
}
PnP PowerShell 更改组设置:
要更改组设置以允许组成员使用 PnP PowerShell 编辑组成员身份,请使用:
#Variable
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"
$GroupName ="Marketing Team Site Owners"
#Connect to PnP Online
Connect-PnPOnline $SiteURL -Credentials (Get-Credential)
#Set Group Settings
Set-PnPGroup -Identity $GroupName -AllowMembersEditMembership $True
要更新网站集中所有组的组设置,请使用以下命令:
#Variable
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"
#Connect to PnP Online
Connect-PnPOnline $SiteURL -Credentials (Get-Credential)
#Get All Groups of the Site collection
$SiteGroups = Get-PnPGroup -Includes AllowMembersEditMembership
ForEach($Group in $SiteGroups)
{
If($Group.AllowMembersEditMembership -ne $True)
{
Set-PnPGroup -Identity $Group -AllowMembersEditMembership $True
Write-host -f Green "Group Settings for '$($Group.Title)' Updated to Edit Membership by Group Members"
}
}
同样,要为租户中的所有网站集配置组设置,请使用以下脚本:
#Variable
$AdminCenterURL = "https://crescent-admin.sharepoint.com"
#Get Credential to connect
$Cred = Get-Credential
#Connect to Admin Center
Connect-PnPOnline $SiteURL -Credentials $Cred
#Get All Site Collections - Exclude: Mysite Host, App Catalog, eDiscovery and Bot catalog Sites
$Sites = Get-PnPTenantSite -Detailed | Where { $_.Template -ne "SPSMSITEHOST#0" -and $_.Template -ne "STS#-1" -and $_.Template -ne "APPCATALOG#0" -and $_.Template -ne "EDISC#0"}
Write-host "Total Number of Sites:"$Sites.Count
ForEach($Site in $Sites)
{
Try {
#Connect to Site collection
Write-host -f Yellow "Processing Site Collection:"$Site.URL
Connect-PnPOnline $Site.URL -Credentials $Cred
#Get All Groups of the Site collection - Exclude SharePoint Online System Groups!
$SiteGroups = Get-PnPGroup -Includes AllowMembersEditMembership | Where {$_.OwnerTitle -ne "System Account"}
ForEach($Group in $SiteGroups)
{
If($Group.AllowMembersEditMembership -ne $True)
{
Set-PnPGroup -Identity $Group -AllowMembersEditMembership $True
Write-host -f Green "`tGroup Settings for '$($Group.Title)' Updated to Edit Membership by Group Members"
}
}
}
Catch {
write-host -f Red "`tError Getting Site Collection!" $_.Exception.Message
}
}
总之,通过允许成员使用 PowerShell 编辑组成员身份,组织可以通过简化在组中添加和删除成员的过程来改善协作和团队合作。您还可以将群组管理职责委派给成员,从而减少管理员的工作量,让他们能够专注于更关键的任务。
