Office 365 – Powershell and Statistics

Problem:

Doing Command Line work on Office 365. Side problem, getting statistics on on-line archive mailbox sizes.

Solution:

  1. Load up Powershell on your PC (it usually comes installed, you just have to search for it)
  2. Run as Administrator
  3. Set-ExecutionPolicy RemoteSigned (only run this one per computer)
  4. $UserCredential = Get-Credential
  5. Type in your credentials
  6. $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  7. Import-PSSession $Session
  8. Check it by running get-mailbox and it should give you a result
  9. When you’re done, you must runĀ  Remove-PSSession $Session otherwise you’ll have issues until the session times out

Checking the mailbox size of your accounts:

  1. get-mailbox | get-mailboxstatistics | ft displayname, totalitemsize

Checking the mailbox size of your online Archive:

  1. Get-Mailbox -Archive -ResultSize Unlimited | Get-MailboxStatistics -Archive | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,TotalItemSize -First 100 (this pulls up the first 100, change it as you see fit)