Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, December 05, 2011

Check in documents with Powershell SharePoint 2010

A simple script shared at @ http://secretsofsharepoint.com/cs/ site for Checking in the documents in a document library using a powershell script.
function CheckInDocument([string]$url)
{
$spWeb = Get-SPWeb $url
$getFolder = $spWeb.GetFolder(“Shared Documents”)
$getFolder.Files | Where { $_.CheckOutStatus -ne “None” } | ForEach
{
Write-Host “$($_.Name) is Checked out To: $($_.CheckedOutBy)”
$_.CheckIn(“Checked In By Administrator”)
Write-Host “$($_.Name) Checked In” -ForeGroundColor Green
}
$spWeb.Dispose()
}
Here’s an example on running the function:
CheckInDocument http://SP

No comments:

Post a Comment