You can use the following code:
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
OR you can Try :
$spWeb = Get-SPWeb http://prinhyltphp0317/
$listName = "text"
$list = $spWeb.Lists |? {$_.Title -eq $listName}
foreach ($item in $list.Items)
{
$itemFile = $item.File
if( $itemFile.CheckOutStatus -ne "None" )
{
$itemFile.CheckIn("Automatic CheckIn. (Administrator)")
}
}
}
$spWeb.Dispose()