Ilse Van Criekinge's Weblog

Addicted to Microsoft Unified Communications

PowerShell Script from TechDays Office365 Demo

PowerShell Script from TechDays Office365 Demo

  • Comments 1
  • Likes

 

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 Smile

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 Smile

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:

IVC-0672

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.

IVC-0673

To change the permission of the Default user to Reviewer, I can run the cmdlet Set-MailboxFolderPermission ilse:\calendar –User default –AccessRights Reviewer:

IVC-0674

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:

IVC-0675

Reason is that Koen doesn’t have a Calendar, but an “Agenda”:

IVC-0676

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 Smile

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

IVC-0677

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 Smile

Get-Mailbox | Get-MailboxFolderStatistics | Where {$_.Foldertype -ilike "calendar"} | select identity | export-csv names.csv

IVC-0678

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 Smile

IVC-0679

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 \ Smile

(Get-Content names.csv) | Foreach-Object {$_ -replace '\\', ':\'} | Set-Content names.csv

IVC-0680

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}

IVC-0681

Checking with Koen’s “Agenda” the script has run successfully Smile

Checking with OWA, it has definitely run successfully Smile

IVC-0683

 

Mission accomplished!

Ilse

Comments
Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment