Get Site Collections per Content Database oneliner

This will be a very short post, as it contains only 1 line of PowerShell code, and is not very hard to understand. It shows you all content databases, and for each of the content databases, it will show you the site collections within this content database.

Thanks for this very helpful pointer. It was *exactly* what I needed. Important to note: It might be obvious to some, but the only Content Databases that will display on the resulting output will be those that are online. If you’ve taken and DBs offline in Central Admin or via Powershell, they won’t show here. 🙂 Thanks again!

All sites within a site collection are stored in the same database. So if your “http://sharepoint.domain.com/sites/hr” is in the “WSS_Content” database, the site “http://sharepoint.domain.com/sites/hr/subsite” will also be in the “WSS_Content” database.