2

I had created a powerShell script to get a list of all the documents added to document libraries across the entire Web Application. But it somehow returned some libraries that did not exist in the error log.

The List Url associated with the error was not to be found anywhere. and this was the error message shown in the log.

one or more field types are not installed properly. go to the list settings page to delete these

I tried to find these lists in the site and also in the SharePoint designer but those could not be found. Can anyone provide me any info on where i can find these lists or why that is causing error.

Any help is appreciated.

The Script

Add-PSSnapin microsoft.sharepoint.powershell

$LogFile="D:\logfile.log"
$listItem=""

function LogWrite()
{
    Param ([string]$logstring)
    Add-content $LogFile -value $logstring
}

function Get-DocInventory() {
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

            $webApp= get-spwebapplication http://sharepointsite.com/
            foreach ($site in $webApp.Sites) {
                foreach ($web in $site.AllWebs) {
                    foreach ($list in $web.Lists) {


                        if (($list.BaseType -ne "DocumentLibrary") -or ($list.Hidden -eq $true)) {
                            continue
                        }
                        try{
                        foreach ($item in $list.Items) {
                            $listItem=$item

                            $data = @{
                                "Web" = $web.Url
                                "List" = $list.Title
                                "Item ID" = $item.ID
                                "Item URL" = $item.Url
                                "Item Title" = $item.Title
                                "Item Created" = $item["Created"]
                                "Item Modified" = $item["Modified"]
                                "File Size in kB" = $item.File.Length/1KB
                            }
                            New-Object PSObject -Property $data
                        }
                        }
                        catch{
                        $error1= " Error occured at :" + $web.Url 
                        $error2= "Item URL:"+ $listItem.Url

                        LogWrite $error1
                        LogWrite $error2
                        LogWrite $_.Exception.Message
                        LogWrite " "
                        }
                    }
                    $web.Dispose();
                }
                $site.Dispose()
            }
     }

Get-DocInventory |export-csv "D:\Docs-Inventory.csv" 
  • Make sure you are using all internal names in your script. It might be different for some of the libraries where you are getting this error. – Ransher Singh Jun 9 '16 at 13:14
  • The lists are looped through $web.Lists , I don't think there is any case of using the internal list name. Correct me if I am wrong. – mallu coder Jun 9 '16 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.