Friday, April 25, 2014

List All Checked Out Items in SharePoint

PowerShell scripts to list out all check-out file from the site and its sub site.  This will help the administrato to find you
the file details that are check-out in the system.

# enter your site URL $spWeb = Get-SPWeb http://kmtechsys/   function GetCheckedItems($spWeb) { Write-Host "Scanning Site: $($spWeb.Url)" foreach ($list in ($spWeb.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) { Write-Host "Scanning List: $($list.RootFolder.ServerRelativeUrl)" foreach ($item in $list.CheckedOutFiles) { if (!$item.Url.EndsWith(".aspx")) { continue } $writeTable = @{ "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)"); "Checked Out By"=$item.CheckedOutBy; "Author"=$item.File.CheckedOutByUser.Name; "Checked Out Since"=$item.CheckedOutDate.ToString(); "File Size (KB)"=$item.File.Length/1000; "Email"=$item.File.CheckedOutByUser.Email; } New-Object PSObject -Property $writeTable } foreach ($item in $list.Items) { if ($item.File.CheckOutStatus -ne "None") { if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue } $writeTable = @{ "URL"=$spWeb.Site.MakeFullUrl("$($spWeb.ServerRelativeUrl.TrimEnd('/'))/$($item.Url)"); "Checked Out By"=$item.File.CheckedOutByUser.LoginName; "Author"=$item.File.CheckedOutByUser.Name; "Checked Out Since"=$item.File.CheckedOutDate.ToString(); "File Size (KB)"=$item.File.Length/1000; "Email"=$item.File.CheckedOutByUser.Email; } New-Object PSObject -Property $writeTable } } } foreach($subWeb in $spWeb.Webs) { GetCheckedItems($subWeb) } $spWeb.Dispose() }   #GetCheckedItems($spWeb) | Out-GridView   # alternative output file GetCheckedItems($spWeb) | Out-File c:\CheckedOutItems.txt -width 300

referred from  this link

No comments:

Post a Comment