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.

1 Answer 1


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


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 and acknowledge you have read our privacy policy.

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