powershell RRS feed

  • Question

  • Hi All

    do we have script to get all folders

    sub folders

    owner of the folder or last modified by in sharepoint document library.



    Tuesday, December 19, 2017 8:14 AM

All replies

  • #Get all lists in farm
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

    #Get the Site collection
    $Site= Get-SPSite http://sharepointsite

    $outputPath = “c:\Portallist.csv”

    Function GetMyFiles($Folder)

    Write-Host “+in : “$Folder.Name
    foreach($file in $Folder.Files)
    Write-Host “`t” $file.Name
    Add-Content -Path $outputPath -Value  ” File Name : $($file.Name)”


    #Loop through all subfolders and call the function recursively
    foreach ($SubFolder in $Folder.SubFolders)
    if($SubFolder.Name -ne “Forms”)
    Write-Host “`t” -NoNewline
    Add-Content -Path $outputPath -Value  ”  Folder Name : $($SubFolder.Name)”



    this is the script Iam using
    Tuesday, December 19, 2017 8:37 AM
  • What is it that is the issue.  What errors are you getting?

    We do not write custom scripts.  You can find scripts in the Gallery for SharePoint.  I suggest starting there.


    Tuesday, December 19, 2017 8:55 AM
  • I am trying to full folders and subfolders under document library with name and owner and modifiedy by

    but it is not generating report



    Tuesday, December 19, 2017 8:58 AM
  • That is because the script you have copied from somewhere is nota capable of accessing SharePoint.    You need to learn SharePoint first and then learn basic PowerShell. 

    Look in the Gallery for hundreds of examples of getting information from SharePoint.  You will also have to install the SharePoint support library and spend a good amount of time learning how to use it.

    I suspect there is at least one script in the Gallery that is very close to what you need.


    Tuesday, December 19, 2017 9:03 AM
  • I should also note that you can attach a document library as a folder in File Explorer which will give you file times and, I believe it will also give you the owner. It will also show you all subfolders. Post in the SharePoint forum for more information on how to attach a library from SharePoint.


    Tuesday, December 19, 2017 9:08 AM