Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用powershell pnp对文件夹的Sharepoint权限_Powershell_Sharepoint_Permissions - Fatal编程技术网

使用powershell pnp对文件夹的Sharepoint权限

使用powershell pnp对文件夹的Sharepoint权限,powershell,sharepoint,permissions,Powershell,Sharepoint,Permissions,命令Get PnPListItem将从列表中检索所有列表项。对于您的需求,您需要遍历文档库中的每个文件夹并应用权限 以下是我的演示: Set-PnPListItemPermission : Cannot convert 'System.Object[]' to the type 'SharePointPnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind' required by parameter 'Identity'. Specifie

命令
Get PnPListItem
将从列表中检索所有列表项。对于您的需求,您需要遍历文档库中的每个文件夹并应用权限

以下是我的演示:

Set-PnPListItemPermission : Cannot convert 'System.Object[]' to the type 'SharePointPnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind' required by parameter 'Identity'. Specified method is not supported.
At line:31 char:53
+ ... t-PnPListItemPermission -List $Listname -Identity $ListitemID -User $ ...
+                                                       ~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-PnPListItemPermission], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,SharePointPnP.PowerShell.Commands.Lists.SetListItemPermission

添加广告组而不是用户对文件夹的权限的最佳方式是什么,因为我们正在探索添加组以更轻松地管理权限。?SharePoint将广告组视为普通用户。所以我认为这种方法也适用于在文件夹中添加AP组。这太棒了@Michael。这起作用令人惊讶。将名称更改为groupm将选择正确的域组并为文件夹分配权限。
Set-PnPListItemPermission : Cannot convert 'System.Object[]' to the type 'SharePointPnP.PowerShell.Commands.Base.PipeBinds.ListItemPipeBind' required by parameter 'Identity'. Specified method is not supported.
At line:31 char:53
+ ... t-PnPListItemPermission -List $Listname -Identity $ListitemID -User $ ...
+                                                       ~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-PnPListItemPermission], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,SharePointPnP.PowerShell.Commands.Lists.SetListItemPermission
$listname="test"
$SiteURL = "https://tenant.sharepoint.com/sites/michael"
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
$ParentFolderURL = "/test" #Site Relative Path of the document Library
$UserAccount = "michael@domain.com"
$AllFolders= Get-PnPFolderItem -ItemType Folder -FolderSiteRelativeUrl $ParentFolderURL | Where {($_.Name -ne "Forms") -and (-Not($_.Name.StartsWith("_")))}

ForEach($Folder in $AllFolders) { 
 #Grant Contribute permissions to the Folder 
Set-PnPListItemPermission -List $ListName -Identity $Folder.ListItemAllFields -User $UserAccount -AddRole 'Read' 
}