Scenario:
During bulk migration, lot of files left checked out because of lack of metadata. We wanted to check-in all these files. Also we want to restrict the script to only "Record Libraries" in record center.
Solution:
Power-shell
Code:
Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue Add-PSSnapin Microsoft.SharePoint.Powershell $rand = new-object System.Random function CheckInDocument([string]$url) { $spWeb = Get-SPWeb $url $SPBaseTypeDocumentLibrary = [Microsoft.SharePoint.SPBaseType]::DocumentLibrary $lists = $spWeb.GetListsOfType($SPBaseTypeDocumentLibrary); foreach ($list in $lists) { if ($list.Hidden -eq $False -and $list.BaseTemplate.ToString() -eq "1302") { Write-Host Checking in documents from Library : $list.Title $getFolder = $spWeb.GetFolder($list.Title) $files = $list.CheckedOutFiles write-host "Total Checked Out Files : " $files.Count $list.CheckedOutFiles | Where { $_.CheckOutStatus -ne "None" } | ForEach { $_.TakeOverCheckOut(); #$docItem = $list.GetItemById($_.ListItemId); #$docItem["Field To Update"] = "Some value"; $docItem.SystemUpdate(); $docItem.File.CheckIn("Checked In By Administrator"); Write-Host "$($docItem.File.Name) Checked In" -ForeGroundColor Green } } } $spWeb.Dispose() } CheckInDocument http://sp2010Article:
3 comments:
Thank you very much. Was help me a lot.I have been looking everywhere for this post. :-)
how to use it?
which variables to change? where do I specify the URL - sorry but never used SP or Power Shell :(
Change you site collection Url in last line of script
Post a Comment