使用 SharePoint Online CSOM,我创建了一个站点并能够在该站点上设置许多内容。使用 CSOM 创建站点时,不会创建默认组。我已经创建了组,但是由于在站点创建过程之外创建组,我现在需要将它们分配为站点上的默认组。
我有以下代码,它在 PowerShell 中没有出现任何错误,但也没有设置组。有没有人设法做到这一点?
$MemberGroupId = 101
$OwnerGroupId = 102
$VisitorGroupId = 103
$Web = $ClientContext.Web
$Groups = $Web.SiteGroups
$ClientContext.Load($Groups)
$ClientContext.ExecuteQuery()
$Web.AssociatedMemberGroup = $Groups.GetById($MemberGroupId)
$Web.AssociatedOwnerGroup = $Groups.GetById($OwnerGroupId)
$Web.AssociatedVisitorGroup = $Groups.GetById($VisitorGroupId)
$Web.Update()
我在几个地方读到了人们遇到的这些 AssociatedMemberGroup、AssociatedOwnerGroup 和 AssociatedVisitorGroup 属性的问题,因此使用 $Web.AllProperties 设置它们,但我不确定如何执行此操作,而且它肯定看起来更复杂方法。