Please find the below PowerShell Code + SharePoint 2013
function CheckedOutItems()
{
$url=Read-Host “Please Enter In Site Url”
”SiteURL ‘t” + “FileName ‘t” + “CheckedOutTo ‘t” + “ModifiedDate ‘t” + “Version” >> c:\temp\checkedoutfiles.csv
$site = New-Object Microsoft.SharePoint.SPSite($url)
$webs = $site.AllWebs
foreach($web in $webs)
{
$listCollections=$web.Lists
foreach($list in $listCollections)
{
if($list.BaseType.ToString() -eq “DocumentLibrary”)
{
$dList=[Microsoft.SharePoint.SPDocumentLibrary]$list
$items = $dList.Items
$files = $dList.CheckedOutFiles
foreach($file in $files
{
$wuse=$file.DirName.Substring($web.ServerRelativeUrl.Length)
$web.Url + “‘t” + $wuse + “‘/” + $file.LeafName + “‘t” + $file.CheckedOutBy.Name + “‘t” + $file.TimeLastModified.ToString() + “‘t” + “No Checked In Version” >> c:\temp\checkedoutfiles.csv
$file.TakeOverCheckOut() #Take ownership of checked out document
}
foreach($item in $list.Items)
{
$item.File.Checkin(“Checked in by Systems Administrator”) #Check document in
if (($list.CheckedOutFiles | Where {$_.ListItemId -eq $item.ID}) -ne $null) {continue}
}
}
}
$web.Dispose()
}
$site.Dispose()
}
CheckedOutItems
function CheckedOutItems()
{
$url=Read-Host “Please Enter In Site Url”
”SiteURL ‘t” + “FileName ‘t” + “CheckedOutTo ‘t” + “ModifiedDate ‘t” + “Version” >> c:\temp\checkedoutfiles.csv
$site = New-Object Microsoft.SharePoint.SPSite($url)
$webs = $site.AllWebs
foreach($web in $webs)
{
$listCollections=$web.Lists
foreach($list in $listCollections)
{
if($list.BaseType.ToString() -eq “DocumentLibrary”)
{
$dList=[Microsoft.SharePoint.SPDocumentLibrary]$list
$items = $dList.Items
$files = $dList.CheckedOutFiles
foreach($file in $files
{
$wuse=$file.DirName.Substring($web.ServerRelativeUrl.Length)
$web.Url + “‘t” + $wuse + “‘/” + $file.LeafName + “‘t” + $file.CheckedOutBy.Name + “‘t” + $file.TimeLastModified.ToString() + “‘t” + “No Checked In Version” >> c:\temp\checkedoutfiles.csv
$file.TakeOverCheckOut() #Take ownership of checked out document
}
foreach($item in $list.Items)
{
$item.File.Checkin(“Checked in by Systems Administrator”) #Check document in
if (($list.CheckedOutFiles | Where {$_.ListItemId -eq $item.ID}) -ne $null) {continue}
}
}
}
$web.Dispose()
}
$site.Dispose()
}
CheckedOutItems
No comments:
Post a Comment