0

Powershell script with csv file of query for (root) site collection, /Finace/ path only.

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:
    • List Type = Library
    • ContentType = Finance Standards Documents or Finance Network Standards Documents or Document And
    • StdsDocStatus = Approved Note: for ContentType, you can also use = Document or Begins With “Finance”
1

There is a demo for your reference.

$siteUrl="http://sp:20971/test1"
$site = New-Object Microsoft.SharePoint.SPSite $siteUrl
$ctName1 = "Finance Standards Documents"
$ctName2 = "Finance Network Standards Documents"
$ctName3 = "Document"
$name="StdsDocStatus"
$file="c:\test\pp4.csv"

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

           foreach ($ctype in $list.ContentTypes)  
             {  

                   if ($ctype.Name -eq $ctName1 -or $ctype.Name -eq $ctName2 -or $ctype.Name -eq $ctName3)  
                   {  


                      if($list.Items.Count -ne 0){

                     foreach($item in $list.items)

                     {

                       if($item[$name] -eq "Approved")
                        {       
                        $item.Fields | foreach { 
             $fieldValues = @{
            "Display Name" = $_.Title
            "Internal Name" = $_.InternalName
            "Value" = $item[$_.InternalName]
        }

         New-Object PSObject -Property $fieldValues | Select @("Display Name","Internal Name","Value")

                        }|Export-Csv -Path $file 



                     }

                         }


                    } 
             } 




        }
        }


        }
        }

enter image description here

More reference: Get all column values from a SharePoint item using PowerShell.

http://get-spscripts.com/2010/09/get-all-column-values-from-sharepoint.html

| improve this answer | |
  • If the reply is helpful to you, you could accept the answer. – Amy_MSFT Feb 10 '18 at 0:54

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.