Find all lists name x in a site collection

%3CLINGO-SUB%20id%3D%22lingo-sub-33209%22%20slang%3D%22en-US%22%3EFind%20all%20lists%20name%20x%20in%20a%20site%20collection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33209%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20SharePoint%20Online%20site%20collection%20with%20~1000%20subsites%20(through%20about%204%20levels).%20About%2070%25%20of%20the%20subsites%20have%20a%20specifically%20named%20task%20list%20I'd%20like%20to%20routinely%20cleanout.%20%26nbsp%3B%3C%2FP%3E%3CP%3ERight%20now%2C%20I'm%20doing%20this%20by%20looping%20through%20all%20the%20Webs.%20%26nbsp%3BIs%20there%20a%20way%20to%20get%20these%20lists%20without%20looping%20through%3F%20A%20way%20to%20find%20all%20lists%20name%20%22xyz%22%20given%20a%20Site%20object%20(or%20Web%20object%20I%20guess)%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33274%22%20slang%3D%22en-US%22%3ERe%3A%20Find%20all%20lists%20name%20x%20in%20a%20site%20collection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33274%22%20slang%3D%22en-US%22%3EYou%20can%20do%20this%20with%20the%20search%20REST%20API%20(GET%20request)%3A%20%3CA%20href%3D%22https%3A%2F%2Ftenant.sharepoint.com%2Fsites%2Fsitecollection%2F_api%2Fsearch%2Fquery%3Fquerytext%3D'STS_LIST_Tasks%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftenant.sharepoint.com%2Fsites%2Fsitecollection%2F_api%2Fsearch%2Fquery%3Fquerytext%3D'STS_LIST_Tasks%3C%2FA%3E%20AND%20Path%3A%22%3CA%20href%3D%22https%3A%2F%2Ftenant.sharepoint.com%2Fsites%2Fsitecollection%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Ftenant.sharepoint.com%2Fsites%2Fsitecollection%3C%2FA%3E%22'%3CBR%20%2F%3E%3CBR%20%2F%3EThis%20query%20will%20return%20all%20lists%20of%20type%20Tasks%20which%20are%20part%20of%20the%20site%20collection.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33271%22%20slang%3D%22en-US%22%3ERE%3A%20Find%20all%20lists%20name%20x%20in%20a%20site%20collection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33271%22%20slang%3D%22en-US%22%3EIt%20is%20only%20possible%20if%20you%20use%20search%20i%20guess%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I have a SharePoint Online site collection with ~1000 subsites (through about 4 levels). About 70% of the subsites have a specifically named task list I'd like to routinely cleanout.  

Right now, I'm doing this by looping through all the Webs.  Is there a way to get these lists without looping through? A way to find all lists name "xyz" given a Site object (or Web object I guess)?

2 Replies
Highlighted
It is only possible if you use search i guess
Highlighted
You can do this with the search REST API (GET request): https://tenant.sharepoint.com/sites/sitecollection/_api/search/query?querytext='STS_LIST_Tasks AND Path:"https://tenant.sharepoint.com/sites/sitecollection"'

This query will return all lists of type Tasks which are part of the site collection.