【问题标题】:Give edit permission to "Everyone" in SharePoint list using PowerShell Client side code使用 PowerShell 客户端代码向 SharePoint 列表中的“所有人”授予编辑权限
【发布时间】:2018-12-15 08:22:37
【问题描述】:

我使用 PowerShell 客户端代码在 SharePoint 网站中创建了一个列表。现在我想编辑这个列表的权限。我想将此列表的编辑权限授予Everyone。这就是我获得Everyone 详细信息的方式:

$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$user  =$Ctx.web.EnsureUser("c:0(.s|true")
$Ctx.Load($user)
$Ctx.ExecuteQuery()

为了打破列表的继承,我使用了这个:

$List = $Ctx.Web.Lists.GetByTitle("ListName")
$Ctx.Load($List)
$Ctx.ExecuteQuery()
$List.BreakRoleInheritance($true)

但我不确定如何将此列表的编辑权限授予Everyone。任何建议都会有所帮助。谢谢

【问题讨论】:

    标签: powershell sharepoint-online sharepoint-list


    【解决方案1】:

    下面是一个示例,说明如何向每个列表的委托人授予 Edit 权限:

    $roleDefinition = $ctx.Site.RootWeb.RoleDefinitions.GetByType([Microsoft.SharePoint.Client.RoleType]::Editor)  
    $roleBindings = New-Object Microsoft.SharePoint.Client.RoleDefinitionBindingCollection($ctx) 
    $roleBindings.Add($roleDefinition)
    $ctx.Load($list.RoleAssignments.Add($user, $roleBindings))
    $ctx.ExecuteQuery()
    

    先决条件

    SharePoint Online Client Components SDK

    【讨论】:

    • 感谢您的回答。是否有任何 dll 依赖项?如果是,那么如何检查 dll 是否已加载?因为有时$user 是空白的。
    • @HarshJaswal,对SharePoint Online Client Components SDK有依赖
    • 感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-17
    • 1970-01-01
    • 2020-07-14
    • 1970-01-01
    • 1970-01-01
    • 2019-02-17
    • 1970-01-01
    相关资源
    最近更新 更多