Script:-
$webAppURL = "Enter your Web application Url"
function ReportCheckedOutItems() {
$webapp = Get-SPWebApplication $webAppURL
foreach ($site in $webapp.Sites)
{
write-host "Site Collection: $($site.Url)"
$allwebs = $site.allwebs
foreach($web in $allwebs)
{
$count = 0
write-host "--Site: $($web.Url)"
foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
Write-Host "-----List: $($list.RootFolder.ServerRelativeUrl)..."
foreach ($item in $list.CheckedOutFiles)
{
if (!$item.Url.EndsWith(".aspx"))
{
continue
}
write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
$count++
}
foreach ($item in $list.Items)
{
if ($item.File.CheckOutStatus -ne "None")
{
if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null)
{
continue
}
write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
$count++
}
}
}
if ($count -gt 0)
{
write-host "Found $count checked out files for site $web" -ForeGroundColor Red
}
}
}
}
ReportCheckedOutItems
$webAppURL = "Enter your Web application Url"
function ReportCheckedOutItems() {
$webapp = Get-SPWebApplication $webAppURL
foreach ($site in $webapp.Sites)
{
write-host "Site Collection: $($site.Url)"
$allwebs = $site.allwebs
foreach($web in $allwebs)
{
$count = 0
write-host "--Site: $($web.Url)"
foreach ($list in ($web.Lists | ? {$_ -is [Microsoft.SharePoint.SPDocumentLibrary]})) {
Write-Host "-----List: $($list.RootFolder.ServerRelativeUrl)..."
foreach ($item in $list.CheckedOutFiles)
{
if (!$item.Url.EndsWith(".aspx"))
{
continue
}
write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
$count++
}
foreach ($item in $list.Items)
{
if ($item.File.CheckOutStatus -ne "None")
{
if (($list.CheckedOutFiles | where {$_.ListItemId -eq $item.ID}) -ne $null)
{
continue
}
write-host "File: $($item.Url) - checked out by $($item.CheckedOutBy)" -ForeGroundColor Red
$count++
}
}
}
if ($count -gt 0)
{
write-host "Found $count checked out files for site $web" -ForeGroundColor Red
}
}
}
}
ReportCheckedOutItems
No comments:
Post a Comment