Following are some of the useful powershell o365 command
# Mailbox details
Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName,PrimarySmtpAddress
Get-Mailbox -identity aditya@sutaantra.com | get-mailboxstatistics | ft displayname, totalitemsize
Get-Mailbox -identity aditya@sutaantra.com | select *quota
Get-Mailbox -identity aditya@sutaantra.com | Select Name,FolderSize,ItemsinFolder | Sort FolderSize
Get-Mailbox -identity aditya@sutaantra.com | Select Name,FolderSize,ItemsinFolder | Sort ItemsinFolder
#Create a new contact
New-MailContact -Name "Aditya saha" -ExternalEmailAddress "aditya@xyz.com"
# Create Distribution group
New-DistributionGroup -Name "info" -DisplayName "Info" -PrimarySmtpAddress info@sutaantra.com -RequireSenderAuthenticationEnabled $false -Members aditya@sutaantra.com,aditya2@sutaantra.com
# Get DL members
Get-DistributionGroupMember -Identity info@sutaantra.com
# Add members to DL
Add-DistributionGroupMember -Identity info@sutaantra.com -Member aditya@sutaantra.com
# Remove member from DL
Remove-DistributionGroupMember -Identity info@sutaantra.com -Member aditya@sutaantra.com
#Connect Msol service
Connect-MsolService
# Reset user password
Set-MsolUserPassword -UserPrincipalName "aditya@sutaantra.com" -ForceChangePassword
Set-MsolUserPassword -UserPrincipalName "aditya@sutaantra.com" -NewPassword "pa$$word"
# Getting calendar permission
Get-MailboxFolderPermission aditya@sutaantra.com:\calendar
# Giving calendar access of mailbox aditya to Joe as editor
Add-MailboxFolderPermission -Identity aditya@sutaantra.com:\calendar -user joe@sutaantra.com -AccessRights Editor
# Removing calendar access of mailbox aditya for Joe
Remove-MailboxFolderPermission -Identity aditya@sutaantra.com:\calendar -user joe@sutaantra.com
# Get & Set message size
Get-TransportConfig | Format-List MaxReceiveSize,MaxSendSize,MaxRecipientEnvelopeLimit
Get-TransportConfig | fl *Max*
Set-TransportConfig -InternalDsnMaxMessageAttachSize 10MB
Set-TransportConfig -ExternalDsnMaxMessageAttachSize 10MB
#Get clutter status
Get-Clutter -Identity aditya@sutaantra.com
#Disable Clutter for user
Set-Clutter -identity aditya@sutaantra.com -Enable $false
#Enable Clutter for user
Set-Clutter -identity aditya@sutaantra.com -Enable $true
#Disable Clutter for all user
Get-Mailbox | Set-Clutter -Enable $false
#Enable Clutter for all user
Get-Mailbox | Set-Clutter -Enable $True
#Setting up auto-reply for mailbox
Set-MailboxAutoReplyConfiguration -Identity aditya@sutaantra.com -AutoReplyState Scheduled -StartTime "7/10/2018 08:00:00" -EndTime "7/15/2018 17:00:00" -InternalMessage "Internal auto-reply message"
Set-MailboxAutoReplyConfiguration -Identity aditya@sutaantra.com -AutoReplyState Scheduled -StartTime "7/10/2018 08:00:00" -EndTime "7/15/2018 17:00:00" -ExternalMessage "Internal auto-reply message"
Set-MailboxAutoReplyConfiguration -Identity aditya@sutaantra.com -AutoReplyState Enabled -InternalMessage "Internal auto-reply message." -ExternalMessage "External auto-reply message."
Set-MailboxAutoReplyConfiguration -Identity aditya@sutaantra.com -AutoReplyState Enabled -ExternalMessage "I am out of the office – if this is urgent, please contact Ben"
Get-MailboxAutoReplyConfiguration -Identity aditya@sutaantra.com
#Disable auto-reply
Set-MailboxAutoReplyConfiguration -Identity aditya@sutaantra.com -AutoReplyState Disabled
#Connection Filtering
New-HostedConnectionFilterPolicy "NewConnectionFilter"
Set-HostedConnectionFilterPolicy "NewConnectionFilter" -IPAllowList x.x.x.x/24,y.y.y.y/24
Set-HostedConnectionFilterPolicy "NewConnectionFilter" -IPBlockList x.x.x.x/24,y.y.y.y/24
Get-HostedConnectionFilterPolicy "NewConnectionFilter"
- KB170077