簡體   English   中英

檢查文檔集中文件/文檔的權限

[英]Check permissions in files/documents within document sets

我試圖遍歷文檔庫中的文檔集,並列出文件/文檔(如果設置了“唯一權限”)。 到目前為止,我已經擁有followin腳本,但是由於某種原因,檢查無法正常進行/恢復預期的結果:

$siteURL = new-object  
Microsoft.SharePoint.SPSite("https://test.code/sites/ITTest")

$web = $siteURL.rootweb

#Getting the required document library
$libraryName = $web.Lists["FurtherTests"]
$rootFolder = $libraryName.RootFolder

#Iterating through the required documents sets
foreach ($docsetFolder in $rootFolder.SubFolders)
{
#check document sets/folders of content type = "TestDocSet"
if($docsetFolder.Item.ContentType.Name -eq "TestDocSet")
{
write-host -f Yellow `t $docsetFolder.Name

#Iterating through the files within the document sets
foreach ($document in $docsetFolder.Files)
{
if(!$document.HasUniqueRoleAssignments)
{
write-host -f Cyan `t "  " $document.Name
write-host -f Red `t "     ..permissions inheritance detected. Process  
skipped"
}

}
}
}

$web.Dispose()
$siteURL.Dispose()

在我的文檔集中,有兩個文檔1具有唯一的權限集,另一個文檔繼承了權限。

我希望該腳本僅向我顯示未設置唯一權限的文檔/文件,但是我會獲取所有文件。 對於上面的獨特權限,我在檢查中遺漏了什么嗎?

在此先感謝您的任何建議。

問題是您要在哪里進行檢查。 斷開的繼承或唯一的角色分配選項實際上在ListItem對象上。 如果按以下方式修改代碼,則它應該可以工作:

if(!$document.Item.HasUniqueRoleAssignments)
{
   write-host -f Cyan `t "  " $document.Name
   write-host -f Red `t "     ..permissions inheritance detected. Process skipped"
}

如果您有任何疑問,請告訴我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM