Skip to content

MS365

Add an auto reply to a Microsoft 365 Group with PowerShell

In a PS Terminal started with Admin permissions source

Set-ExecutionPolicy Remotesigned  
Install-Module -Name Microsoft.Graph -Scope AllUsers  
Install-Module -Name ExchangeOnlineManagement  
Install-Module -Name Microsoft.Online.SharePoint.PowerShell  
Connect-ExchangeOnLine -ShowProgress $true  
Set-MailboxAutoReplyConfiguration -Identity "IT Department" -ExternalMessage "This email address does not accept messages." -AutoReplyState Enabled -ExternalAudience All

Retrieve the total mailbox size and the folder count for a mailbox

Get-MailboxFolderStatistics -Identity "nobody@somewhere.com" | Select-Object Name, FolderAndSubfolderSize, ItemsInFolderAndSubfolders | Select-Object -First 1

Set the time zone for a shared mailbox

Set-MailboxRegionalConfiguration -Identity "The new shared mailbox" -TimeZone "Eastern Standard Time"

Set shared mailbox messages to be copied to said mailbox's Sent Items

set-mailbox blahblah@domain.com -MessageCopyForSentAsEnabled $True                      
set-mailbox blahblah@domain.com -MessageCopyForSendOnBehalfEnabled $True

Retrieve shared mailbox and group access a particular account has been granted access to.

https://raw.githubusercontent.com/sachapan/365/refs/heads/main/ListSharedAccess.ps1

Query Dynamic List members

Get-DynamicDistributionGroupMember -Identity "Cheyenne Office" | Format-Table DisplayName

Find mailboxes over quota

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where-Object {$_.StorageLimitStatus -eq "IssueWarning" -or $_.StorageLimitStatus -eq "ProhibitSend"}

Quarantine messages

Get-QuarantineMessage