我正在尝试遍历文档库并将每个文档/项目设置为继承权限(目前每个文档/项目都使用唯一权限)。
我能够获得特定的文档库,但是我无法遍历其中的每个项目/文档。这是我到目前为止所拥有的:
Add-Type -Path "Libraries\Microsoft.SharePoint.Client.dll"
Add-Type -Path "Libraries\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "Libraries\Microsoft.SharePoint.Linq.dll"
Add-Type -Path "Libraries\Microsoft.SharePoint.dll"
$webUrl = "https://test.sharepoint.com/sites/testsite"
$username = "####"
$password = "####"
$securePass = ConvertTo-SecureString $password -AsPlainText -Force
$listname = "TestDoc";
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePass)
#variables
$web = $ctx.Web
$lists = $web.Lists
$ctx.Load($lists)
$ctx.Load($web)
$ctx.ExecuteQuery()
#print web URL
write-host `n "Web Url:" `n $web.Url
foreach ($list in $lists)
{
if ($list.Title -eq "TestDoc")
{
#print list name if found
write-host `n "Found the list:" `n $list.Title `n
#attempting to iterate through items in the document library
foreach ($item2 in $list.Items)
{
#list the items/documents in the document library
write-host $item2.Title
}
}
}
这是我目前遇到问题的 foreach 循环,因为我不确定如何遍历文档库中的每个项目/文档。
任何关于我应该采取的方法的建议将不胜感激。