Now that PowerShell works pretty well on macOS, including remote sessions to Office 365, I’m able to use it a lot more for administering client tenancies in the cloud.
One common task is to set the default sharing on a new user’s calendar to let everyone else in the organisation view all details, instead of just free/busy information.
For all my PowerShell remote sessions to Office 365, I have saved a script that will perform the initial connection, and it goes something like this:
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
This will prompt you for the admin credentials for your Office 365 tenancy and then establish a remote connection. Once you’re authenticated, you can execute commands that run against the Office 365 servers.
To set the default calendar sharing on a user’s calendar to provide everyone with Reviewer status, simply run the following command:
Set-MailboxFolderPermission [email protected]:\calendar -User Default -AccessRights Reviewer
This changes the default sharing permissions for all users to Reviewer (can see all event details, but can’t change anything).
To give a another user a different level of access, instead of Set-MailboxFolderPermission, you need to use Add-MailboxFolderPermission, e.g.:
Add-MailboxFolderPermission [email protected]:\calendar -User [email protected] -AccessRights Editor
Once the user’s permission has been added with Add-MailboxFolderPermission version of the command, then you can make any required changes with Set-MailboxFolderPermission.
You can then check the permissions on anyone’s calendar like so:
Get-MailboxFolderPermission [email protected]:\calendar
Last, but not least, you can remove a user’s permissions on a calendar via:
Remove-MailboxFolderPermission [email protected]:\calendar -user "Full Name"
Or, via their email address:
Remove-MailboxFolderPermission [email protected]:\calendar -user [email protected]