Forum Discussion

Darren Rose's avatar
Darren Rose
Brass Contributor
Dec 09, 2018

Using MicrosoftGraph API in C# (or VB) to access mailbox usage information

Hi

 

Currently I use a powershell script such as below to get sizes of mailboxes in my organization

 

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking

$ExportFile = ([Environment]::GetFolderPath("Desktop")+"\Mailboxes.csv")

Get-Mailbox | Get-MailboxStatistics | Select DisplayName, TotalItemSize, ItemCount | Sort ItemCount -Descending | Export-CSV $ExportFile -NoTypeInformation

Remove-PSSession $Session

 

But I want to start programming using the Microsoft Graph API so I can write an app to pull out various bits of information - the first of which is the mailbox 

 

Using the example here = https://github.com/microsoftgraph/console-csharp-snippets-sample I can connect to my Office 365 / Exchange Online mailbox and pull out information

 

But I can't see where I can get mailbox statistics such as mailbox size like I can get using my powershell

 

Perhaps someone can point me in the right direction? or comment if better way of doing it?

 

Basically want to regularly check sizes and send alert when particular mailboxes get too large (usually ones used by a service account rather than a user)

 

Many thanks

3 Replies

Resources