Disable Creation of New Folder in Existing Document Libraries
Scenario:
You have a SharePoint farm with many Site collections and document libraries. You have decided that you want to disable the creation of new libraries in all Document libraries.
Solution:
You could manually edit the settings of every library or you could run the below PowerShell script:
Add-PSSnapin Microsoft.SharePoint.PowerShell
#If you know the site URL that you want to affect just change $sites to "Get-SPSite "http://{siteurl}" otherwise all sites will be affected
#Get list of sites in the farm
$sites = Get-SPSite -Limit All | Get-SPWeb -Limit All
#Get list of document libraries in the farm and remove system folders from the list
$folders = $sites.folders | where {($_.name -ne "FormServerTemplates") -and ($_.name -ne "Style Library") -and ($_.name -ne "SiteAssets")}
#Get a list of document librarys that are actual document libraries and not catalogs etc...
$items = $folders.properties | where {$_.vti_listservertemplate -eq "101" }
#Grab the title of the remaining libraries
$libs = $items.vti_listtitle
#Remove duplicate items from the list
$itemsclean = $libs | select -Unique
#Run through the list of libraries
foreach($i in $itemsclean){
Write-Host "Changing Library " $i
$list = $sites.lists | where title -eq $i
#Set the folder creation value to false
$list.EnableFolderCreation = $false
#Update the value
$list.Update()
Write-Host "Changed " $i
}