簡體   English   中英

SharePoint Online CSOM關聯網站用戶組AssociatedMemberGroup AssociatedOwnerGroup AssociatedVisitorGroup

[英]SharePoint Online CSOM Associated Site Groups AssociatedMemberGroup AssociatedOwnerGroup AssociatedVisitorGroup

使用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設置了它們,但我不確定如何執行此操作,而且它看起來似乎更為復雜方式。

不知道您是否找到了解決方案。 如果沒有,請嘗試以下操作:

$groups = $web.SiteGroups
$clientContext.Load($groups)
$clientContext.ExecuteQuery()

$group = $groups.GetByName("Your Visitors Group Name")
$clientContext.Load($group)

$web.AssociatedVisitorGroup = $group
$web.Update()

$clientContext.ExecuteQuery()

讓我知道它是如何工作的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM