首先停止继承权限

$web = Get-PnPweb
$spoList= Get-PnPList "Testlist" -Web $web (注释:获取对象)
$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 '读取'
}

最新文章

  1. C#部分---类、异常保护;
  2. DS18B20 for STM32 源代码 【worldsing笔记】
  3. fedora21安装xmind7
  4. 通过定时监听input框来实现onkeyup事件-
  5. Bzoj 1657: [Usaco2006 Mar]Mooo 奶牛的歌声 单调栈
  6. 微信支付[v3]
  7. python简易爬虫实现
  8. Python3基础 setdefault() 根据键查找值,找不到键会添加
  9. 老李推荐:第5章7节《MonkeyRunner源码剖析》Monkey原理分析-启动运行: 循环获取并执行事件 - runMonkeyCycles
  10. c# 小小备忘录
  11. JAVA IO分析三:IO总结&文件分割与合并实例
  12. 微信小程序 --- 无法跳转到tab页面问题
  13. Linux报错之ping: www.baidu.com: Name or service not known
  14. Clustering[Introduction]
  15. GitHub18
  16. hdu 5256 最少修改多少个数 能使原数列严格递增 (LIS)
  17. Javascript-可莱托指数判断
  18. golang中的字符串拼接
  19. ubuntu关闭系统自动检测错误
  20. react input 设置默认值

热门文章

  1. php . extension_loaded
  2. OpenFOAM——三角腔驱流
  3. 【转】理解Docker容器网络之Linux Network Namespace
  4. 对异步处理的http接口进行性能测试
  5. MySQL8.0项目启动遇到的问题
  6. 太厉害了,终于有人能把TCP/IP协议讲的明明白白了!
  7. python爬虫中XPath和lxml解析库
  8. wamp64显示黄色图标不能忍
  9. 一篇文章学会shell脚本
  10. 移动端播放直播流(video.js 播放 m3u8 流)