Monday, January 16, 2012

Powershell script update draft version Sharepoint 2010

#Get site object and specify name of the library to look for in each site
$site = Get-SPSite http://yoursite.com/
$lookForList = "Shared documents"
#Walk through each site and change draft settings on the list specified
$site | Get-SPWeb -Limit all | ForEach-Object {
   
    write-host "Checking site:"$_.Title
   
    #Make sure the library exists
    $docLibrary = $_.Lists[$lookForList]
   
    if ($docLibrary -ne $null)
    {
        $docLibrary.DraftVersionVisibility = 1
        $docLibrary.Update()
 write-host $docLibrary.Title "on site" $_.Title "is updated"
    }
    else
    {
        write-host "The list" $lookForList "does not exist in site" $_.Title
    }
}
#Dispose of the site object
$site.Dispose()

No comments:

Post a Comment