Domanda

I ran the following powershell however, it only list 20 items and in reality I have about 50 items for the site I am running for. I am the farm and site admin. I see 50 files when I go to the library setting manage checked out files http://inside.nv.ed/teams/mkt/_layouts/ManageCheckedOutFiles.aspx?List=%7BBF36234B%2D0303%2D470D%2D887C%2D3A4724FFCB58%7D. Any idea why there is a discrepancy?

Add-PSSnapin Microsoft.SharePoint.PowerShell

$spWeb = Get-SPWeb "http://inside.nv.ed/teams/mkt"
foreach ($list in ($spWeb.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
    #Write-Host "Scanning List: $($list.RootFolder.ServerRelativeUrl)"
    $CAML = "<Where><Geq><FieldRef Name='CheckoutUser' LookupId='TRUE'/><Value Type='int'>0</Value></Geq></Where>"
    #$CAML = "<where><isnull><fieldref lookupid='TRUE' name='CheckoutUser'></fieldref></isnull></where>"
    $query = new-object Microsoft.SharePoint.SPQuery
    $query.ViewAttributes = "Scope='Recursive'" 
    $query.Query = $CAML
    $listitems = $list.GetItems($query)
    #write-host $listitems.Count
    foreach ($item in $listitems)
    {      
        #write-host $item.url
        $fullURL=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)")
        write-host $fullURL
    }

}
È stato utile?

Soluzione

Either it's a bug or by design by Microsoft. We are in the process of migration and we have received tons of complaints that their files are missing. I have no choice but hit the sql db directly. here is the sql query that worked like I intended. I am NOT liable if your record(s) locks up due to this query. Use at your own risk.

1. Go to the database and open an new sql query window (from sql management)
2. Execute following query
SELECT TOP 1000 *
  FROM [WSS_Content_NOV].[dbo].[AllDocs]
  where SiteId='E2FF98A7-B719-428D-8C30-856F08989691' and 
  CheckoutUserId is not null
3. Export the output to excel or csv for department review
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top