Exchange Powershell Calendar Permissions

This is a brief write-up on how to connect to exchange and change the permissions of calendars for a domain through powershell. This was tested with Office 365.

Make sure you are running powershell in administrator mode, and have enabled scripts to run. If you’re not sure you can run the command:

Get-ExecutionPolicy
# If the policy is set to restricted, run this command:
Set-ExecutionPolicy RemoteSigned

Connecting to Exchange

$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session

Changing Permissions

If you have never changed anything before on the domain, you will need to enable domain customizations. This may take a while, but should eventually show a status at the top of powershell. Once enabled, you do not need to run this command again.

Enable-OrganizationCustomization

Now, you need to know what the policy name is before you can edit it:

Get-Mailbox -Identity user@yourdomain.com |fl *SharingPolicy*
# An example of what it returns:
# SharingPolicy : countableset.onmicrosoft.com\Default Sharing Policy

In this case the policy name for my domain is “Default Sharing Policy”, for the rest of the commands this is the name I will use. If yours is not the same substitute yours policy name instead.

To see what the policy is set to run this command:

Get-SharingPolicy -Identity "Default Sharing Policy" |fl *Domains*
# Will return something like:
# Domains : {Anonymous:CalendarSharingFreeBusyDetail}

To change the policy, run the command:

Set-SharingPolicy -Identity "Default Sharing Policy" -Domains "anonymous:CalendarSharingFreeBusyDetail"

Where “CalendarSharingFreeBusyDetail” is the permission for an “anonymous” user.

To change the policy for different domains or add in different domains, add in the domain and permissions afterward:

Set-SharingPolicy -Identity "Default Sharing Policy" -Domains "anonymous:CalendarSharingFreeBusyDetail", "nulldirective.ch:CalendarSharingFreeBusyDetail"

Disconnect

Remove-PSSession $Session