{"id":171,"date":"2011-06-15T16:00:06","date_gmt":"2011-06-15T15:00:06","guid":{"rendered":"http:\/\/www.mysticslayer.com\/?p=171"},"modified":"2011-06-15T16:00:06","modified_gmt":"2011-06-15T15:00:06","slug":"powershell-update-all-document-libraries-with-majorversionlimit-and-majorwithminorversionslimit","status":"publish","type":"post","link":"https:\/\/www.mysticslayer.com\/?p=171","title":{"rendered":"Powershell: Update all Document Libraries with MajorVersionLimit and MajorWithMinorVersionsLimit"},"content":{"rendered":"<p>I had to write a Powershell script to run thru all sites in a Web Application to enable Versioning. As well Major as Minor versions. With of course a limit on Major and Minor versions.<\/p>\n<p>Next script should do the trick:<\/p>\n<div><code>Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue<br \/>\n$siteURL = $args[0]<br \/>\n$site = Get-SPSite($siteURL)<\/code><\/div>\n<div><code><\/code><\/div>\n<div><code>foreach($web in $site.AllWebs) {<br \/>\n\u00a0Write-Host \"Inspecting \" $web.Title<br \/>\n\u00a0foreach ($list in $web.Lists) {<br \/>\n\u00a0\u00a0if($list.BaseType -eq \"DocumentLibrary\") {<br \/>\n\u00a0\u00a0Write-Host \"Versioning enabled: \" $list.EnableVersioning<br \/>\n\u00a0\u00a0$host.UI.WriteLine()<br \/>\n\u00a0\u00a0Write-Host \"MinorVersioning Enabled: \"\u00a0 $list.EnableMinorVersions<br \/>\n\u00a0\u00a0$host.UI.WriteLine()<br \/>\n\u00a0\u00a0Write-Host \"EnableModeration: \" $list.EnableModeration<br \/>\n\u00a0\u00a0$host.UI.WriteLine()<br \/>\n\u00a0\u00a0Write-Host \"Major Versions: \" $list.MajorVersionLimit<br \/>\n\u00a0\u00a0$host.UI.WriteLine()<br \/>\n\u00a0\u00a0Write-Host \"Minor Versions: \" $list.MajorWithMinorVersionsLimit<br \/>\n\u00a0\u00a0$host.UI.WriteLine()<br \/>\n\u00a0\u00a0$list.EnableVersioning = $true<br \/>\n\u00a0\u00a0$list.EnableMinorVersions = $true<br \/>\n\u00a0\u00a0$list.MajorVersionLimit = 2<br \/>\n\u00a0\u00a0$list.MajorWithMinorVersionsLimit = 5<br \/>\n\u00a0\u00a0$list.Update()<br \/>\n\u00a0\u00a0Write-Host $list.Title \" is updated with MajorVersionLimit 2 and MajorwithMinorVersionsLimit = 5\"<br \/>\n\u00a0\u00a0}<br \/>\n\u00a0}<br \/>\n}<\/code><\/div>\n<p><code>\u00a0<\/p>\n<p><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had to write a Powershell script to run thru all sites in a Web Application to enable Versioning. As well Major as Minor versions. With of course a limit on Major and Minor versions. Next script should do the trick: Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue $siteURL = $args[0] $site = Get-SPSite($siteURL) foreach($web in $site.AllWebs) { [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3,262,224],"tags":[44,310,309,362,52,223,308],"class_list":["post-171","post","type-post","status-publish","format-standard","hentry","category-blog","category-powershell","category-sharepoint-2010","tag-document-library","tag-majorversionlimit","tag-minorversion","tag-powershell","tag-sharepoint","tag-sp2010","tag-versioning"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pe1EH-2L","_links":{"self":[{"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/posts\/171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=171"}],"version-history":[{"count":5,"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions"}],"predecessor-version":[{"id":176,"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions\/176"}],"wp:attachment":[{"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mysticslayer.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}