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 Answer 1


There is a demo for your reference.

$site = New-Object Microsoft.SharePoint.SPSite $siteUrl
$ctName1 = "Finance Standards Documents"
$ctName2 = "Finance Network Standards Documents"
$ctName3 = "Document"

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.


  • If the reply is helpful to you, you could accept the answer.
    – Amy_MSFT
    Commented Feb 10, 2018 at 0:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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