You need to modify the script
according to your requirements. The below script does a check-in of all the
documents forcefully in a document library. Similarly you could customize the
script to check-out all the documents.
$listname = "testdoc"
function approveContent ($w, $listName) {
$list = $w.Lists |? {$_.Title -eq
$listName}
foreach ($item in $list.Items)
{
if(($item
-ne $null) -and ($item.LockId -ne $null)) {
$item.ReleaseLock($item.LockId)
}
if( $item.File -ne $null) {
$itemFile = $list.GetItemById($item.ID).File }
else { $itemFile =
$list.GetItemById($item.ID) }
if(
$itemFile.CheckOutStatus -ne "None" ) {
$itemFile.CheckIn("Automatic
CheckIn. (Administrator)")
if( $item.File -ne
$null) { $itemFile = $list.GetItemById($item.ID).File }
else { $itemFile =
$list.GetItemById($item.ID) }
}
}
}
$site = Get-SPSite $url
foreach ( $web in $site.AllWebs )
{
approveContent $web $listname
}
Write-Output "OK"
Note : Before running this script please take a backup of the
lists and libraries.
No comments:
Post a Comment