SharePoint中用Power shell命令设置文档库列表的权限
2024-10-19 17:26:21
首先停止继承权限
$web = Get-PnPweb
$spoList= Get-PnPList "Testlist" -Web $web (注释:获取对象)
$spoList.BreakRoleInheritance($true, $true)(注释:停止继承)
$spoList.Update()(注释:标记)
$spoList.BreakRoleInheritance($true, $true)(注释:停止继承)
$spoList.Update()(注释:标记)
$spoList.Context.Load($spoList)(注释:)
$spoList.Context.ExecuteQuery() (执行)
--利用excel表格批量列表停止继承权限
$web = Get-PnPWeb
$filename="C:\Users\bobo\Desktop\list.csv"
ConvertFrom-Csv (gc $filename) | ForEach-Object{
$currentList=Get-PnPList $_.Name -Web $web
$currentList.BreakRoleInheritance($true, $true)
$currentList.Update()
$currentList.context.Load($currentList)
}
$web.context.ExecuteQuery()
list.csv附件地址:https://files-cdn.cnblogs.com/files/xingyunqiu/list.zip
--利用筛选条件批量停止继承权限
我是利用“创建时间”进行筛选的
$web = Get-PnPWeb
Get-PnPList | Where-Object "Created" -GE 2018-12-17|ForEach-Object{
$_.BreakRoleInheritance($true, $true)
$_.Update()
$_.context.Load($_)
}
$web.context.ExecuteQuery()
设置列表文档库单个用户的权限
Set-PnPListPermission -Identity '测试文档库' -User 'yuancb@kfgs.com.cn' -AddRole '读取'
设置单个列表的用户组权限
Set-PnPListPermission -Identity '测试文档库' -Group "读取权限组" -AddRole '读取'
对多个列表设置列表单个人或单个组的权限
$filename="C:\Users\bobo\Desktop\list.csv"
ConvertFrom-Csv (gc $filename) | ForEach-Object{
Set-PnPListPermission -Identity $_.Name -Group "读取权限组" -AddRole '读取'
}
最新文章
- C#部分---类、异常保护;
- DS18B20 for STM32 源代码 【worldsing笔记】
- fedora21安装xmind7
- 通过定时监听input框来实现onkeyup事件-
- Bzoj 1657: [Usaco2006 Mar]Mooo 奶牛的歌声 单调栈
- 微信支付[v3]
- python简易爬虫实现
- Python3基础 setdefault() 根据键查找值,找不到键会添加
- 老李推荐:第5章7节《MonkeyRunner源码剖析》Monkey原理分析-启动运行: 循环获取并执行事件 - runMonkeyCycles
- c# 小小备忘录
- JAVA IO分析三:IO总结&;文件分割与合并实例
- 微信小程序 --- 无法跳转到tab页面问题
- Linux报错之ping: www.baidu.com: Name or service not known
- Clustering[Introduction]
- GitHub18
- hdu 5256 最少修改多少个数 能使原数列严格递增 (LIS)
- Javascript-可莱托指数判断
- golang中的字符串拼接
- ubuntu关闭系统自动检测错误
- react input 设置默认值