0
我正在尝试向组权限添加组。我的代码如下:尝试将组权限添加到库权限时,在CSOM PowerShell中获取通用“集合未加载”错误
#earlier in my code the list is created so it's already stored at this point, Breaking Inheritance is successful
$myList.BreakRoleInheritance($false,$true)
$myList.Update()
$Ctx.ExecuteQuery()
$GroupnameMembers="Site Members"
$roleDefs = $Ctx.Web.RoleDefinitions
$webgroups = $Ctx.Web.SiteGroups
$Ctx.Load($roleDefs)
$Ctx.Load($webgroups)
$Ctx.ExecuteQuery()
$roleTypeContributor = [Microsoft.SharePoint.Client.RoleType]"Contributor"
$roleDefContributor = $roleDefs | where {$_.RoleTypeKind -eq $RoleTypeContributor}
$MembersGroup = $webgroups | Where{$_.Title -eq $GroupnameMembers}
$ContributorRoleDefBinding = new-object Microsoft.SharePoint.Client.RoleDefinitionBindingCollection($Ctx)
$ContributorRoleDefBinding.Add($roleDefContributor)
#earlier in my code the list is created so it's already stored at this point
$collRoleAssign = $myList.RoleAssignments
$Ctx.Load($collRoleAssign)
$Ctx.ExecuteQuery()
#Crashing on this line below:
$collRoleAssign.Add($MembersGroup, $ContributorRoleDefBinding)
我用尽了一切我能想到的,我甚至手动通过代码加强,我仍然无法找到的问题,我已经在每个阶段扔在调试输出和证实它们是在最终代码片段中使用的所有3个变量的值。
任何帮助/建议将不胜感激。