SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I´m searching for an good way to find the ContentQuery WebPart in my WebApplication. My plan is to write a PowerShell script and create a url list.

I found the following possible ways:

  • SharePoint Object model, I think to slow because I must check every page
  • SQL query, fast but not possible in my environment.

Are there also other ways? Is it possible to use CAML?

share|improve this question
Using the object model, coupled with the SPLimitedWebPartManager, is faster than you think. – James Love Oct 31 '11 at 13:11
Also, see this StackOverflow question (for MOSS 2007) :… – SHug Oct 31 '11 at 16:14
up vote 1 down vote accepted

If you're looking for a PowerShell script then I've written one before to do this kind of thing. I've done this several times to find custom web parts that have been in our solution and needed updating following a new release.

My script lists all web parts but it is easily modified to filter out based on the type value of the web part (modify the $wps variable).

share|improve this answer

The SharePoint Object Model is the (only supported) way to do it.

share|improve this answer
You are not allowed to access the Content Databases with SQL as far as i know. – Stefan Bauer Oct 31 '11 at 20:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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