Como utilizar:
Observação: Edite o PowerShell para alterar o local onde o arquivo CSV será salvo.
1 - Execute o Script.
2 - Será solicitado o login e senha.
3 - Coloque a suas credenciais do Office 365.
Mais informações: https://gallery.technet.microsoft.com/office/Office-365-Mailbox-Sizes-08e24bde
Resultado do PowerShell
Código PowerShell (Salvar com extensão .ps1)
################################################################################################################################################################
# Script that creates Report the size of e-mail accounts Office 365
#
# Script accepts 2 parameters from the command line
#
# Office365Username - Optional - Administrator login ID for the tenant we are querying
# Office365Password - Optional - Administrator login password for the tenant we are querying
#
#
# To run the script
#
# .\SendO365MailStats.ps1 [-Office365Username admin@xxxxxx.onmicrosoft.com] [-Office365Password Password123]
#
#
# Author: Daniel Gimenes Violin
# Version: 1.0
# Last Modified Date: 12/11/2015
# Last Modified By: Daniel Gimenes Violin daniel.violin@gmail.com
################################################################################################################################################################
#Accept input parameters
Param(
[Parameter(Position=0, Mandatory=$false, ValueFromPipeline=$true)]
[string] $Office365Username,
[Parameter(Position=1, Mandatory=$false, ValueFromPipeline=$true)]
[string] $Office365Password
)
#Constant Variables
$OutputFile = "c:\Shellpro\logs\SendO365MailStats.csv" #The CSV Output file that is created, change for your purposes
#Remove all existing Powershell sessions
Get-PSSession | Remove-PSSession
#Did they provide creds? If not, ask them for it.
if (([string]::IsNullOrEmpty($Office365Username) -eq $false) -and ([string]::IsNullOrEmpty($Office365Password) -eq $false))
{
$SecureOffice365Password = ConvertTo-SecureString -AsPlainText $Office365Password -Force
#Build credentials object
$Office365Credentials = New-Object System.Management.Automation.PSCredential $Office365Username, $SecureOffice365Password
}
else
{
#Build credentials object
$Office365Credentials = Get-Credential
}
#Create remote Powershell session
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $Office365credentials -Authentication Basic –AllowRedirection
#Import the session
Import-PSSession $Session -AllowClobber | Out-Null
#get report and save a file
get-mailbox | get-mailboxstatistics | select DisplayName,ItemCount,TotalItemSize | export-csv $OutputFile