1

I have been scouring google and could not find anything to go off of in regards to my task. Like the title suggests, I'm trying to utilize a powershell script to output all folders residing in a Site Collection down to its sites and subsites. In addition to what I mentioned, I would like to display the owner of the folders. If anyone has came across this any help would be appreciated.

2

Use below code, it will iterate all the webs under the specified site collection, It will get all the document library and it will iterate all the folders in the document libraries and gives the folder name and its author.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get the Site collection 
$Site= Get-SPSite "SiteURL" 
       #Loop throuh all Sub Sites
       foreach($Web in $Site.AllWebs)
       {
        Write-Host "-----------------------------------------------------"
        Write-Host "Site Name: '$($web.Title)' at $($web.URL)"
        Write-Host "-----------------------------------------------------"
        foreach($list in $Web.Lists)
        {
           #Filter Doc Libs, Eliminate Hidden ones
            if(($List.BaseType -eq "DocumentLibrary") -and ($List.Hidden -eq $false) )
               { 
                GetFiles($List.RootFolder)
               }
        }
}

Function GetFiles($Folder)
{ 
  Write-Host "Folder Name: " $Folder.Name;
  Write-Host "Folder Author: " $Folder["Author"];

   #Loop through all subfolders and call the function recursively
     foreach ($SubFolder in $Folder.SubFolders)
        {
            if($SubFolder.Name -ne "Forms")
            {  
                Write-Host "`t" -NoNewline
                GetFiles($Subfolder)

            }
        }
}
  • I have tested script and it outputs folders as expected but as for Folder Author it displays blank for all. For testing purposes I even created a folder with only me (Author) as the owner of the folder. I then ran script, looked for my newly created folder with me being the only user with permissions to it and Folder Author still displays blank. What am I missing here? – Aspire27 Jan 13 '16 at 17:28

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.