The following macros are not currently supported in the header:
  • style

How to Find all Pages or Documents with specific text, HTML, Web Parts, JavaScript, CSS, etc...

Author: The content of this macro can only be viewed by users who have logged in.

Description

You can use the Item Query report to find text, web parts, large files, old files, files modified by specific people, files with many versions, web pages with errors, and much more

Step-by-Step

There are often times when working with SharePoint where you need to find specific content, text or even HTML code throughout the site. Most of the time you rely heavily on either a manual check or search to find what you need. Both of these options can be time consuming and often not return the content you are looking for.

Within the SharePoint Essentials Toolkit, you can utilize the “Item Query” feature to find any type of text or content easily. Within one of the pages in the On-premises SharePoint site, a page has been created that contains a SharePoint Script Editor web part with the following code:

This code simply draws a square with a button and text field allowing you to change the color of the square.

If you wanted to find all instances of this code then you would have to manually check page by page. However, with the toolkit you can run crafted queries that will search all content for this. To create this query, open the Essential SharePoint Toolkit and click the SharePoint button on the top navigation.

Next select the Content button from the top navigation, then expand the Discover, menu and select Item Query.

UPDATE: (SET v5.9.0.0) You can now also select one or more sites from the Home Page Dashboard to perform a Query against.

From the Item Query window, set the Job Name, and then select the Site Url to Scan.

Next ensure the Credentials are set that match the SharePoint connection that you selected. The bulk of the configuration is then completed within the Query Options section of the Item Query window.

Selecting the first dropdown allows you to set to either Include or Exclude specific queries. The second dropdown allows you to choose how you want to find this data you are searching for by using various properties and the file content itself.

Once you have selected to Include or Exclude, and then the property to search within, you can then determine the comparison from the dropdown.

The text field can then be populated with the text value or values you are looking for in the content. For the JavaScript function example, you can use: “function ChangeDivColor“.

As with any query in the toolkit you can then also add Inclusion Rules, Email options and Export option. For this simply leave these as the default, so the results are returned within the tool itself. Now Save the job, and then select the Schedule Job button to set the job to run immediately.

Once you have scheduled the job, you will then be taken to the schedule grid where the newly created job is now listed.

Right click on the job and select the Run Now option which will cause the newly created job to run.

Once the job is completed the Job Status will display Complete. Now you can right click, select the View Reports item and then select the Item Query Report.

The results of the job will now be displayed. As you can see, it has found the page that contains the JavaScript.

If needed right clicking on the entry will allow you to go direct to the item itself. In this instance, it will take you to the properties for the page, not the page itself.

Export

You can then take your results and export them to Excel/CSV/SharePoint.

Using the Item Query option, you can be very specific and granular when searching over the content. It is a very powerful feature of the SharePoint Essentials Toolkit.


Liam Cleary - SharePoint MVP

Liam Cleary - SharePoint MVP

SharePoint MVP & Part-Time Blogger at QiPoint
Liam began his career as a Trainer of all things computer-related. He quickly realized that programming, breaking, and hacking was a lot more fun. He spent the next few years working within core infrastructure and security services, until he found SharePoint. He now works as a Solution Architect for Protiviti in Virginia. His core focus is to ensure that SharePoint can either natively, or with minimal customization, meet the business requirement. He is also a ten time SharePoint MVP focusing on Architecture but also crosses the boundary into Development. His specialty over the past few years has been security in SharePoint and its surrounding platforms. He can often be found at user groups or conferences (such as Microsoft Ignite) speaking, offering advice, spending time in the community, teaching his kids how to code, raspberry PI programming, hacking the planet, or building LEGO robots.



©2018 QiPoint
2500 Plaza 5, 25th Floor
Harborside Financial Center
Jersey City, NJ 07311 http://www.qipoint.com

Microsoft, Windows, SharePoint, and the SharePoint logos, are either registered trademarks or trademarks of Microsoft Corporation.