In my powershell script, I get all lists, then loop through and filter based on if its a document library and if its a certain content type, but I want to do this through CAML.

This is the loop logic

# get all the lists from the source location
$sourceLists = $sourceWebObj.Lists;

# loop through all lists
foreach ($sourceList in $sourceLists) {

    # check if it's a valid document library and it's content type is what we want
    if($sourceList.BaseType -eq "DocumentLibrary" -and $sourceList.ContentTypes[$DocLibContentType] -ne $null) {


How can I do the same thing with CAML?



CAML query is used to get information from List.

You requirement is to filter Lists which belongs to object Web. We can't use CAML for that.

I would suggest you use PowerShell piping etc.


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.