Skip to content

Instantly share code, notes, and snippets.

@tuyendq
Last active September 28, 2022 15:24
Show Gist options
  • Save tuyendq/a48577791dd3b4052d73ec39263b38b8 to your computer and use it in GitHub Desktop.
Save tuyendq/a48577791dd3b4052d73ec39263b38b8 to your computer and use it in GitHub Desktop.
Office 365
$today = Get-Date -Format yyyyMMdd
# Install the Microsoft Graph Powershell module
Install-Module Microsoft.Graph
# Install the Microsoft Azure AD module
Install-Module AzureAD
# Using credential
$credential = Get-Credential
Connect-AzureAD
# Disconnect the current session
Disconnect-AzureAD
# Connect to Azure AD
Connect-AzAccount
Get-AzADUser -UserPrincipalName <...@...>
# Connect to Exchange Online
Connect-EXOPSSession -UserPrincipalName <...@...>
Connect-MsolService
Get-MsolUser | Export-Csv -Path D:\\MicrosoftOffice365\Users-${today}.csv -NoTypeInformation
# Get specific mailbox statistics
$today = Get-Date -f yyyyMMdd
Get-MailboxFolderStatistics -Identity <...@...> -FolderScope All | select Name,ItemsInFolderAndSubfolders,FolderAndSubfolderSize | Export-Csv -Path mailbox-$today.csv -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment