Create report site collection size in SharePoint

With the following PowerShell script is it posible to obtain the size of each one of the site collections of a WebApplication and send the report by mail


##########Create Report########################################
$Date = Get-Date -Format dMyyyy
$DateReport = Get-Date -Format d/M/yyyy
$Path = "C:"
$NameFile = "SitesSize.csv"
$FullName = $Path + $Date + $NameFile
Get-SPWebApplication "https://yoururlwebapp" | Get-SPSite | select url, @{label="Size in MB";Expression={"{0:n2}" -f (($_.usage.storage/1024)/1024)}}, @{label="Date Report";Expression={$DateReport}} | Format-table -auto | out-file $FullName
#####################################################################
##############Send Emain######################################
$smtpServer = "ServerSMTP"
$To = "mailTO@domain.com"
$From = "mailFROM@domain.com"
$Subject = "Report Site Size"
$Body = "Attach Report Site Size"
$file = get-childitem $FullName -recurse | % {$_.FullName}
send-mailmessage -from $From -to $To -subject $Subject -body $Body -Attachments $file -priority High -dno onSuccess, onFailure -smtpServer $smtpServer
#####################################################################

Hope it helps

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s