I need confluence Page IDs for all pages containing a specific string.
Asked by Peter DeWitt:

OK,here is the scenario. We have a Confluence instance that is a number of years old. Over the years users have created many pages (2000+) that contain passwords in plain text. Our security team has a list of these passwords and they need to remove them from the pages they appear on and remove the history of those pages. They would like us to generate a list of page URLs for them. If we have the page IDs we can concatenate the URLs in excel.

1. Does anyone have any ideas on how to do this either through the API or direct to DB?

2. Has anyone come across a utility that would allow the scrubbing of specific strings within all of Confluence; find and replace like?


Answers:
author: Stephen Deutsch
body: Here's another option:

[Search and Replace User Macro](https://streamline.atlassian.net/wiki/spaces/STRMLN/pages/5144578/Search+and+Replace+User+Macro)

You could use this to search for the search terms, and it will create a table in Confluence with links that you could copy and paste into Excel, and then you wouldn't even have to look up the IDs. Either that or I could modify it so it would display the IDs as well.

It has replace functionality too, so you could use it to make the necessary changes. It has a preview option so you can see what changes it is making to the code of the page.

comments: author: Davin Studer
body: Pretty slick user macro! I might be using this myself for some manual replacements I have been doing.


author: AnnWorley
body: I am not sure how to generate a list of URLs with the particular strings (passwords) but as far as a search and replace strategy, you could try a procedure similar to: [How Do I replace all 'hard' links to my old Base URL](https://confluence.atlassian.com/confkb/how-do-i-replace-all-hard-links-to-my-old-base-url-284366235.html) The first two options will replace content in historical page versions.


author: Davin Studer
body: [Keysight Admin Tools for Confluence](https://marketplace.atlassian.com/plugins/com.keysight.confluence-support/server/overview) has a utility for find and replace throughout the whole wiki. Use with caution and test first on a non-prod version. :)


author: Alexey Matveev
body: You can use Confluence CLI. You can find more information here:

<https://bobswift.atlassian.net/wiki/plugins/servlet/mobile?contentId=32571427#content/view/48398579>


author: Davin Studer
body: If you want a SQL query to find the pages this should get you what you want.

```
select S.SPACENAME, C.*
from CONTENT C
inner join BODYCONTENT B on C.CONTENTID = B.CONTENTID
inner join SPACES S on C.SPACEID = S.SPACEID
where 
    C.PREVVER is null
    and C.CONTENT_STATUS = 'current'
    and (C.CONTENTTYPE = 'PAGE' or C.CONTENTTYPE = 'BLOGPOST')
    and B.BODY like '%YourStringHere%'
order by S.SPACENAME, C.TITLE
```


author: Peter DeWitt
body: Guys, tanks for the answers. This is exactly what I was looking for. Options. :)

comments: author: Davin Studer
body: If we get to choose our **tanks** I'm gonna have to go with the good old Sherman.

![TankshermanM4.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/9049i91576992C01902A3/image-dimensions/373x279?v=v2 "TankshermanM4.jpg")