0

I am trying to get the permissions users have on each and every document under a specific site collection (e.g. https://test.com)

This is what I tried:

function Get-DocumentInventory([string]$siteUrl) {
$site = New-Object Microsoft.SharePoint.SPSite $siteUrl


foreach ($web in $site.AllWebs) {
    foreach ($list in $web.Lists) {
    if ($list.BaseType -ne “DocumentLibrary”) {
        continue
    }

foreach ($item in $list.Items) {
$data = @{
            "Web Application" = $webApp.ToString()
            "Site" = $site.Url
            "Web" = $web.Url
            "list" = $list.Title
            "Item ID" = $item.ID
            "Item URL" = $item.Url
            "Item Title" = $item.Title
            "Item Created" = $item["Created"]
            "Item Modified" = $item["Modified"]
            "File Size" = $item.File.Length/1KB
            "Permissions" = $role.Member 
                                }
New-Object PSObject -Property $data
}
}
$web.Dispose();
}
$site.Dispose()
}
Get-DocInventory "https://test.com/" | Out-GridView
Get-DocInventory "https://test.com/" | Export-Csv -NoTypeInformation -Path C:\Users\livob002-lap\Desktop\PermissionTest.csv

The PermissionTest.csv is created, however it is empty and the GridView does not open.

I am using SharePoint 2013 Collaboration Platform.

I also have full rights/permissions to the servers and farm.

Any ideas what I could be doing wrong?

0

In your ps code,

$data = @{
            "Web Application" = $webApp.ToString()

replace webApp by web

Also, replace the function name to Get-DocInventory. It does not match the function calls at the end of the script.

2
  • Thanks! However all the Item Titles are getting shown as Microsoft.SharePoint.SPListItem. i.imgur.com/ETtEijb.png
    – Brian
    Jan 12 '17 at 8:55
  • Nevermind, added $item.["Title"] and it worked :) Thanks!
    – Brian
    Jan 12 '17 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.