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 example.user@mydomain.com:\calendar

View the permissions for a specific user:

  • Get-MailboxFolderPermission -Identity calendar@mydomain.com:\Calendar -User dude@mydomain.com

Add permissions to the calendar:

  • Add-MailboxFolderPermission calendar@mydomain.com:\Calendar -User dude@mydomain.com -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 dude@mydomain.com

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 support.byteblower.kayakoqueue@excentis.com -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:

WordPress.com Logo

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s