Approve files in library

27/07/2012 18:10

$siteUrl="http://blogs/blog3"
$web=get-spweb $siteUrl

$folder=$web.GetFolder("Pages")  #("_catalogs/masterpage")        
$files=$folder.Files
$layouts=@($files["NewsLayoutDetails.aspx"])
     
write-host "Approving files..."

# check-in
foreach($spFile in $files) #$layouts)
{
    if($spfile.checkOutStatus -ne "None" -and $spfile.checkOutStatus -ne $null)
    {
        $spfile.checkIn("Checked in by Powershell", [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn)
    }
}
write-host "Files approved."