I am trying to create a script that will iterate through specified site collections and find all files which have a specified data in the custom column named for eg. colours.

in this coloumn it's a required info column and would contain for eg. Either, Red, Blue or Green.

I can create a script that finds all files in a site collection not a problem, but i'm struggling with how to script something that all finds files that have an entry in the "Colours" column of Red,Blue or Green, then out put the the details of the file to csv containing, SC, Site, Library, Custom Column data eg(colour), size, last modified and URL.

Any help greatly greatly appreciated.

  • Is this a Site Column? Also, what version of SharePoint? Sep 5 '17 at 13:03
  • It is. Sp2013. However I have now managed to create a script that reports all the relevant information. Thanks for responding anyway.
    – grizzly
    Sep 6 '17 at 13:25
  • Shall add script in later.
    – grizzly
    Sep 6 '17 at 13:26

If you are using CSOM with PowerShell to loop all documents from site, you can load the meta data (columns) of files. E.g.,

$fileprop = $context.web.GetfileByserverRelativeURl($fileurl) 
$FileColumns = $fileprop.ListItemAllFields
if($Filecolumns["Yourcolourcolumn"]) -eq "Red")
 write-host   "$fileurl has been marked red"

You can read the set of site URLs from an input file on which you want to run this search and run the PowerShell command specified in this post to export the relevant values.

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.