Blog written by:
Liam Cleary
SharePoint MVP
Intro
There are often times when working with SharePoint where you need to find specific content, text, web parts, 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, web page controls, web parts, or content easily. Item Query will search within metadata, page contents, file content such as even PDFs, MS Office files to find matches.
An example use case:
Users have gotten hold of some HTML and JavaScript with is causing some issues and you need to find where this code has been copied and pasted throughout the portal. Within a SharePoint Script Editor web part the following code is found:
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 SharePoint Essentials Toolkit and click the SharePoint button on the top navigation.
Select one or more sites from the Home Page Dashboard to perform a Query against them.
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.
- SharePoint Top 5 Features for Newbies - December 17, 2018
- SharePoint versus OneDrive - December 17, 2018
- How to Cleanup SharePoint User Permissions - July 25, 2017