Hi @Rohini Dhale ,
Yes. To fetch all the libraries from a site that contain documents with missing required fields, you can use PowerShell script to loop through the libraries and check the number of items in the “File That need attention” view. This view filters the documents that have empty values in required columns. You can use the Get-PnPView
cmdlet to get the view object and the Get-PnPListItem
cmdlet to get the items in the view. You can also use the Get-PnPList
cmdlet to get all the libraries in the site. Here is a sample script that you can have a try:
#Connect to SPO
Connect-PnPOnline -Url “https://tenant.sharepoint.com/sites/sitname” -Interactive
#Get all the libraries in the site
$allLibs = Get-PnPList | Where-Object {$_.BaseType -eq “DocumentLibrary”}
#Initialize a variable to store the count of libraries with missing required fields
$libCount = 0
#Loop through each library
foreach($lib in $allLibs) {
#Get the “File That need attention” view object
$view = Get-PnPView -List $lib -Identity “File That need attention”
#Get the number of items in the view
$itemCount = (Get-PnPListItem -List $lib -Query $view.ViewQuery).Count
#If the item count is greater than zero, increment the libCount variable
if($itemCount -gt 0)
{
$libCount++
}
Copy
}
#Output the result
Write-host “The number of libraries with missing required fields is $libCount”
Hope this helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.