Recently was requested to set the calendar permissions for all our Office 365 mailboxes.
Here are the instructions:

Create a password file for the Office 365 user

Read-Host -AsSecureString “Office 365 password?” | ConvertFrom-SecureString | Out-File C:\Scripts\Office365cred.txt

Create a powershell scritp file UpdateCalendar-O365.ps1

if ((Get-PSSnapin | Where-Object {$_.Name -like "Microsoft.Exchange.Management.PowerShell.E2010"})){
Remove-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Write-Output "Loading O365 Environment"

Set-ExecutionPolicy RemoteSigned
$User = “”

$Pass = Get-Content C:\Scripts\Office365cred.txt | ConvertTo-SecureString
$PSCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $Pass
$O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Authentication Basic -AllowRedirection -Credential $PSCred
$ImportSession = Import-PSSession $O365Session

Write-Output “Loaded O365 Environment”

Write-Output “Loading mailboxes”
#Custom variables
$mailboxes = Get-Mailbox -ResultSize Unlimited

Write-Output “Loaded mailboxes”
$AccessRights = “Reviewer”

#Loop through all mailboxes
foreach ($mailbox in $mailboxes) {

Write-Output “Looking up $mailbox”
$calendar = (($mailbox.Identity)+ “:\” + (Get-MailboxFolderStatistics -Identity $mailbox.Identity | where-object {$_.FolderType -eq “Calendar”} | Select-Object -First 1).Name)

$access = ((Get-MailboxFolderPermission $calendar | Where-Object {$_.User -like “Default”}).AccessRights)

#Check if calendar-permission for user “Default” is set to the default permission of “AvailabilityOnly”
if ($access -like “AvailabilityOnly” ) {
Write-Output ” Updating calendar permission for $mailbox…”
#Set calendar-permission for user “Default” to value defined in variable $AccessRights
Set-MailboxFolderPermission -User “Default” -AccessRights $AccessRights -Identity $calendar
} elseif ($access -like $AccessRights ) {
Write-Output ” $AccessRights calendar permission for $mailbox already set.”
} elseif ($access -like “None” ) {
Write-Output ” Changing calendar permission for $mailbox from None…”
#Set calendar-permission for user “Default” to value defined in variable $AccessRights
Set-MailboxFolderPermission -User “Default” -AccessRights $AccessRights -Identity $calendar
} else {

Write-Output ” Permission set to $access for $mailbox.”

Write-Output “Removing O365 Environment”
Remove-PSSession $O365Session
Write-Output “Removed O365 Environment”

Within Task Scheduler, Create New Task…
Specify the name, run whether user is logged on or not, and Run with highest privileges.

Set the triggers

Under the Actions Tab:

Program = C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add arguments = -command "C:\scripts\UpdateCalendar-O365.ps1" > "C:/scripts/UpdateCalendar-O365-Output.txt"

This should generate an output script text file so you can monitor the progress.