Script to find all site collections within database

In SharePoint 2013 by rhodzyLeave a Comment

A handy little script to find all site collections in a certain content database which emails the results via PowerShell. Change the items in bold

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$X = Get-SPSite -Limit All -ContentDatabase CONTENTDATABASENAME | select url, @{label=”Size”;Expression={$_.usage.storage}} | out-string
Send-MailMessage -SmtpServer SMTPSERVERNAME -Subject “YOUREMAILSUBJECT” -Body $X -To SOMEONE@rzy.co -From FROMADDRESS@rzy.co