1

Is it possible to disable folder creation for the whole site collection instead of only on library?

1

Actually No, Since Folder creation is a feature of List/Library; So you can not do this at site level. But there is an alternative way do achieve the same. You can run a power-shell script which will loop through all the List/Library based on your selected Template. there you can set property

EnableFolderCreation to false

below is the sample code for your reference:

$sites = Get-SPSite 'http://<site name>' | 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" }
$libs = $items.vti_listtitle 
$itemsclean = $libs | select -Unique

#Run through the list of libraries
foreach($i in $itemsclean){    
    $list = $sites.lists | where title -eq $i
    $list.EnableFolderCreation = $false
    $list.Update()    
}

Edit: For SP Online using CSOM code

ClientContext clientContext = new ClientContext("http://your-site-url"); 
Web web = clientContext.Web;
ListCollection listColl = web.Lists;
foreach(List lst in listColl)
{
    if(lst.BaseType -eq "DocumentLibrary"){
        lst.EnableFolderCreation = false;
        lst.Update();
    }
}
clientContext.ExecuteQuery();
  • This is for SharePoint Online so the above would need to be converted into CSOM code, but in theory yes the correct approach. – Thomas Gass Jul 20 '17 at 9:57
  • 1
    Ahh, Thanks for pointing out. I have updated my answer – DvG Jul 20 '17 at 10:14
  • @j.Cup.. see this famous CSOM+Powershell introduction for SP Online-- sharepointnutsandbolts.com/2013/12/… – DvG Jul 20 '17 at 10:55
  • This is the first time i am going to use powershell for the company. I in stalled SharePoint online management shell and did the following on the beginning: $adminUPN="aaaaaa" $orgName="xxxxxx" $userCredential = Get-Credential -UserName $adminUPN -Message "Type the password." Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential After this i am supposed to immediately add your code? Is there a tutorial somewhere so i don't have to ask the basic things? – j. Cup Jul 20 '17 at 11:20
  • Please see my comment above for tutorial reference – DvG Jul 20 '17 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.