Wiki – Exchange online Powershell examples

Welkom at the Exchange online Powershell examples Wiki.

Before you are able to perform any of the below powershell examples, you will need to connect to Exchange online using powershell.   

Steps on how to do this can be found on the: Howto – Install and Connect to Exchange online remote powershell with 2FA

Add calender permissions in a mailbox:

View the current permissions:

  • Get-MailboxFolderPermission\calendar

View the permissions for a specific user:

  • Get-MailboxFolderPermission -Identity\Calendar -User

Add permissions to the calendar:

  • Add-MailboxFolderPermission\Calendar -User -AccessRights Author

Note: AccessRights can be: Owner, PublishingEditor, Editor, PublishingAuthor, Author, NonEditingAuthor, Reviewer, Contributor, AvailabilityOnly, LimitedDetails

Remove permissions for a specific user

  • Remove-MailboxFolderPermission -Identity calendar@company:\calendar -user

What if you need to change the calendar permissions for all users within your organization?!

$allmailbox = Get-Mailbox -Resultsize Unlimited
Foreach ($Mailbox in $allmailbox)
    $path = $Mailbox.alias + “:\” + (Get-MailboxFolderStatistics $Mailbox.alias | Where-Object { $_.Foldertype -eq “Calendar” } | Select-Object -First 1).Name
    Set-mailboxfolderpermission –identity ($path) –user Default –Accessrights AvailabilityOnly

List all folders in a mailbox

Get-MailboxFolderStatistics -Identity username.e | select-object identity

Enable out of office message for a mailbox via powershell

Set-MailboxAutoReplyConfiguration -Identity <username> -AutoReplyState Enabled -InternalMessage “Internal auto-reply message.” -ExternalMessage “External auto-reply message.”

Export distribution group members to csv file

Get-DistributionGroupMember -identity “mydistributionlist” | export-csv -NoTypeInformation -path.\mydocument.csv -encoding utf8

Insert a mailbox rule to silently discard auto-reply messages

New-InboxRule -mailbox -Name NoAutoReplyMessages -SubjectContainsWords “Automatic reply” -DeleteMessage $true


Published by

Ronny Van den Broeck

I'm a network and system engineer for more than 20 years now. During this period I became a pro in hunting down one's and zero's, with an eager mindset to help people accomplish the same or abstract them away from the matrix.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s