0

I'm new to powershell and trying to loop through all document libraries of a site and find/output those file locations into a CSV which have a custom column value equals Null.

Any link or sample code would be very helpful.

Please note we are using Sharepoint 2016 on-premise.

0

One sample to start with:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$webs = (Get-SPSite "<SiteURL>" | Get-SPWeb -Limit all -ErrorAction SilentlyContinue)
$Lists = $webs.Lists
$ListItemCollection = @()

Foreach($List in $Lists) {
    if($List.BaseType -eq "DocumentLibrary"){
        $list.Items | Where-Object { $_["<ColumnInternalName>"] -eq Null} | foreach {
            $ExportItem = New-Object PSObject
            $ExportItem | Add-Member -MemberType NoteProperty -name "URL" -value $_.URL
            $ExportItem | Add-Member -MemberType NoteProperty -name "Name" -value $_["Name"]
     
            #Add the object with property to an Array
            $ListItemCollection += $ExportItem
        }
    }
}
$ListItemCollection | Export-CSV "C:\Temp\LibData.csv" -NoTypeInformation

References:

Export SharePoint List Items to CSV using PowerShell.

Get items from SharePoint List using PowerShell script.

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.