Wouldn't you just add that to your 'if'?
if ($list.BaseType -eq "DocumentLibrary" -and $list.BaseTemplate -eq "DocumentLibrary" -and $list.EnableVersioning -eq $false)
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I have a script which enable/update all document library on a web app in SharePoint 2013 :
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
Write-Host "Starting to update lists and Libraries"
$webs = get-spsite -limit all | get-spweb -Limit All
foreach ($web in $webs)
{
Write-Host "Updating Site" $web -foregroundcolor Black -backgroundcolor Yellow
foreach ($list in $web.lists)
{
Write-Host "Looking at list $list"
if ($list.BaseType -eq "DocumentLibrary" -and $list.BaseTemplate -eq "DocumentLibrary")
{
Write-Host "Updating list $list" -foregroundcolor Black -backgroundcolor Green
$list.EnableVersioning = $true;
$list.EnableMinorVersions = $false;
$list.EnableModeration = $false;
$list.MajorVersionLimit = 10;
$list.ForceCheckout = $false;
$list.Update()
}
}
$web.Dispose()
}
Write-Host "Done updating lists!" -foregroundcolor Black -backgroundcolor Green
I would like to add an exception : if there is already versioning enabled on a site, I don't want any update on it.
Is that possible ?
Thank you very much for your help.
Best regards,
Andy
Wouldn't you just add that to your 'if'?
if ($list.BaseType -eq "DocumentLibrary" -and $list.BaseTemplate -eq "DocumentLibrary" -and $list.EnableVersioning -eq $false)