PowerShell Script from TechDays Office365 Demo
Today I have had the privilege of doing both a BreakOut Session on Secure Remote Access in Lync, and a Demo Session on Office365, together with my colleague Koen Van Tolhuyzen, at the TechDays in Antwerp!
In this demo session, we tried to show off the wonderful world of Office365, in the limited time of 35minutes…which was actually too short, but I’m happy we have been able to show some of the nice features included, as the just-released New Time Management Application, for which you can find more information here: http://www.microsoft.com/presspass/features/2011/apr11/04-27CalendarAnalytics.mspx
As promised, here’s the PowerShell script I used to demonstrate Exchange Management Shell, against our O365 tenant. And as said, you can use this one as well against your Exchange On Premise Organization
Question/Challenge: is it possible to grant everyone Reviewer permission to everyone’s calendar in your Exchange Organization?
Answer: sure, by using a simple Shell script
Step 1. Definition of the problem
When I try to open up the calendar of one of my colleagues, by default I can only see whether he/she is busy or not, as shown in the print screen below:
Step 2. Resolve the problem
The problem is that by default, the default user has got the permission of “AvailabilityOnly” on the calendar…in order to see full details, I could change the value to Reviewer, as an example. Let’s see…
To see the permissions for the calendar, I can use the cmdlet Get-MailboxFolderPermission, so to retrieve the permission set on the calendar of the mailbox belonging to Ilse, I can enter: Get-MailboxFolderPermission ilse:\calendar.
To change the permission of the Default user to Reviewer, I can run the cmdlet Set-MailboxFolderPermission ilse:\calendar –User default –AccessRights Reviewer:
Step 3. Another Issue Pops Up
Now I would like to change the permission on the calendar of Koen, but when running the cmdlet Get-MailboxFolderPermission koen:\calendar, I end up with the following error:
Reason is that Koen doesn’t have a Calendar, but an “Agenda”:
So, in order to change the permissions on the calendar, we need to get a hold of the folder names… we can use the cmdlet Get-MailboxFolderStatistics
Step 4. Retrieve the Folder Namings
In order to retrieve the folder names for all mailboxes in your organization, we can use the following Shell line:
Get-Mailbox | Get-MailboxFolderStatistics | Where {$_.Foldertype -ilike "calendar"} | ft identity,name,folderpath
When you export this output to an excel file, you can use it as input to change the permissions for everyone to Reviewer on everyone’s calendar
Get-Mailbox | Get-MailboxFolderStatistics | Where {$_.Foldertype -ilike "calendar"} | select identity | export-csv names.csv
Step 5. Another issue pops up
In order to change the permissions, you need to define the name of the folder as “userid”:\”foldername”, but when looking at the content of the names.csv file, it only shows “userid”\”foldername”. In order to change the \ to :\, you could use notepad, and do a find replace (as I did in the demo session), but off course you could use the shell for this
Running the following line, will get the content op names.csv; and replace the \ with :\. Since \ is a reserved character in PowerShell, you will need to escape it using a \
(Get-Content names.csv) | Foreach-Object {$_ -replace '\\', ':\'} | Set-Content names.csv
Step 6. The Single Shell Line to replace the Permissions on everyone’s calendar, to grant the Default User the permission of “Reviewer”.
Running this line will open every mailbox, and set the permission of the default user to Reviewer:
Import-Csv Names.csv | % { Set-MailboxFolderPermission -Identity $_.Identity -AccessRights Reviewer -User Default}
Checking with Koen’s “Agenda” the script has run successfully
Checking with OWA, it has definitely run successfully
Mission accomplished!
Ilse
Comments
Anonymous
September 15, 2011
I have created a script for Exchange 2010 that can be reused for Office 365. I demoed it in TechDays in Norway. You dont have to use csv file to import users. msunified.net/.../script-set-calendarpermissions-ps1Anonymous
December 03, 2015
The comment has been removedAnonymous
December 03, 2015
The comment has been removed