Posts

Showing posts from August, 2022

Running SQL Queries On Sitecore Databases Using Sitecore PowerShell Extensions

Image
  Whether you are developing on Sitecore or supporting a live Sitecore instance, there are times you need to access the SQL databases to run queries to fetch some data. While the Sitecore APIs provide access to the items in the content tree, they are not very useful when you want to check the old login tickets in core database, or need to inspect the JWT tokens received from identity provider when using federated authentication.  There are many reasons for a Sitecore developer to want to access the Sitecore database. I am sure there are equal if not more number of reasons for the security team to deny access. Many a times you would be an admin on the Sitecore instance but won't even have read-only access to the SQL databases. In this article I am going to show how you can run simple queries on the Sitecore databases using the power of SPE. For this to work, you need to have access to use the PowerShell ISE on the Sitecore instance. First, we will need to fetch the connection string