function GetCheckedOutFiles($web)
{
Write-Host "Processing Web: $($web.Url)..."
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
}
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.CheckedOutByUser;
"CheckedOutByEmail"=$item.File.CheckedOutByUser.Email
}
New-Object PSObject -Property $hash
}
}
}
foreach($subWeb in $web.Webs)
{
GetCheckedOutFiles($subweb)
}
$web.Dispose()
}
$web = get-spweb $args[0]
GetCheckedOutFiles($web)
{
Write-Host "Processing Web: $($web.Url)..."
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
}
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.CheckedOutByUser;
"CheckedOutByEmail"=$item.File.CheckedOutByUser.Email
}
New-Object PSObject -Property $hash
}
}
}
foreach($subWeb in $web.Webs)
{
GetCheckedOutFiles($subweb)
}
$web.Dispose()
}
$web = get-spweb $args[0]
GetCheckedOutFiles($web)
No comments:
Post a Comment