Issue : To get all the checkout files by users in a web application .
Resolution:
I had write this power shell script to get all the checkout file from web application. I had used the power shell code from Gary’s script and Modify to used for SharePoint 2007.
Script :
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.Sharepoint”)
$webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup(“http://Sharepointwebapp”)
foreach ($site in $webapp.Sites) {
Write-Host “Processing Site: $($site.Url)..”
foreach ($web in $site.AllWebs)
{
Write-Host -foregroundcolor red “Processing Web: $($web.Url)…”
# To get the Checked out Pages
foreach ($list in ( $web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]}) ) {
Write-Host “`tProcessing List: $($list.RootFolder.ServerRelativeUrl)…”
foreach ($item in $list.CheckedOutFiles) {
if (!$item.Url.EndsWith(“.aspx”)) { continue }
$hash = @{
“URL”=$web.Site.MakeFullUrl(“$($web.ServerRelativeUrl.TrimEnd(‘/’))/$($item.Url)”);
“CheckedOutBy”=$item.CheckedOutBy;
“CheckedOutByEmail”=$item.CheckedOutByEmail
}
New-Object PSObject -Property $hash
}
# To get the Checkout documents in Libraries
foreach ($item in $list.Items) {
if ($item.File.CheckOutStatus -ne “None”) {
if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue }
$hash = @{
“URL”=$web.Site.MakeFullUrl(“$($web.ServerRelativeUrl.TrimEnd(‘/’))/$($item.Url)”);
“CheckedOutBy”=$item.File.CheckedOutBy;
“CheckedOutByEmail”=$item.File.CheckedOutBy.Email
}
New-Object PSObject -Property $hash
}
}
# To get Managed Check Out Files
foreach ($item in $list.CheckedOutFiles ){
if ($item.File.CheckOutStatus -ne “None”) {
if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null) { continue }
$hash = @{
“URL”=$item.Url;
“CheckedOutBy”=$item.CheckedOutBy;
“CheckedOutByEmail”=$item.CheckedOutBy.Email
}
New-Object PSObject -Property $hash
}
}
}
$web.Dispose()
}
}