1

Can someone please help me to powershell query of webApp/ (root) site collection, /finance/ path only.

The web App instance is fine for as a design platform.

We need a list of documents with the following columns in the CSV output file in the column order given.

  • Column Display Value
  • Internal Column Name

Write the output to a CSV filename with the name, StdsandRelatedDocuments.csv. Order by Path then ContentType, then Name. Include a Send Email instruction at the beginning and at the end of the run. Parameterize all appropriate elements.

The selection criteria is as follows:

  1. From libraries in all sub webs in the /Finance/ path.
  2. Where

a. List Type = Library

b. ContentType = Finance Standards Documents or Finance Network Standards Documents or Document And

c. StdsDocStatus = Approved Note: for ContentType, you can also use = Document or Begins With “Finance”

0

Please check following PowerShell function that exports a report of documents as per your conditions. It is not perfect solution, you may need to tweak it to suit your needs.

function Get-DocInventory([string]$siteUrl) {
$site = New-Object Microsoft.SharePoint.SPSite $siteUrl
$ctName1 = "Finance Standards Documents"
$ctName2 = "Finance Network Standards Documents"

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

        foreach ($ctype in $lst.ContentTypes)  
             {  
                   if ($ctype.Name -ne $ctName1 -And $ctype.Name -ne $ctName2 -And $ctype.Name -ne "Document")  
                   {  
                        continue
                    } 
             } 

        foreach ($item in $list.Items) {

            if($item["StdsDocStatus"] -eq "Approved"){

                $data = @{
                "Item URL" = $item.Url
                "Item Title" = $item.Title
                "Item Created" = $item["Created"]
                "Item Modified" = $item["Modified"]
                "Created By" = $item["Author"]
                "Modified By" = $item["Editor"]
                }
            }
        New-Object PSObject -Property $data
        }
    }
    $web.Dispose();
}
$site.Dispose()
}

You can invoke this function as given below:

Get-DocInventory "http://yourSitePath" | Export-Csv -NoTypeInformation -Path "c:\Document_Detail_Report.csv"
  • Thanks Sagar but the above code doesn't working for me.Can you please Export csv file to get all documents with columns for all the sites in an site collection using powershell with above scenario – Pradeep Reddy Jan 19 '18 at 11:23
  • Can someone pls help me with proper solution – Pradeep Reddy Jan 19 '18 at 11:48

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.