Link to home
Start Free TrialLog in
Avatar of ieg
iegFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How can I set all calendar appointments to "private"

The business I work for uses MS Exchange and Outlook for the mail and calendar systems.
Up until now access to individual employees' calendars by colleagues has been at the employee's discretion.
To make it easier to organise meetings we have recently taken a decision to have an "Open Calendar" policy across the group.
This means that we will automatically set all the calendars to have open access from within our company.

The problem however is that once open the calendars can be browsed into the past and many people have appointments in their calendars that should not be open to the public.

So, I am looking for a way to set all appointments prior to Jan 1st 2019 to "private".
We have in-house c# skills  and I was wondering if it is possible to write something that could be run against a calendar setting all appointments to private. Presumably we would have to target the Exchange server directly to do this. But we have no experience in doing this so I was hoping for guidance from someone.

Any advice on how to go about this would be greatly appreciated.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of DevAdmin
DevAdmin
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Exchange itself has nothing allowing to set the flag directly. You need to simulate or use an email client for that, i.e. EWS (as interface) or Outlook (on each machine).
The  PowerShell approach using the local Outlook is:
$dt = get-date '2019-01-01'

$olk = New-Object -COM Outlook.Application
$olk.session.Folders |
% {  try { $_.Folders("Calendar") } catch {} } |
  Select -Expand Items |
  ? { $_.Sensitivity -ne 2 -and $_.Start -lt $dt } |
  % { $_; $_.Sensitivity = 2; } |
  ft Subject, Sensitivity, Start, End

Open in new window

Running that code will cause an Outlook security prompt to allow for external access to Outlook (which is ok here, of cause). Then it will process all calendar folders, and look for entries older than the date boundary you set up in the first line.
If you want to restrict it to the default account (where the inbox is located):
$dt = get-date '2019-01-01'

$olk = New-Object -COM Outlook.Application
$olk.session.GetDefaultFolder(9) |
  Select -Expand Items |
  ? { $_.Sensitivity -ne 2 -and $_.Start -lt $dt } |
  % { $_; $_.Sensitivity = 2; } |
  ft Subject, Sensitivity, Start, End

Open in new window

Avatar of ieg

ASKER

Thanks to both of you. Both solutions worked. We decided on Ermanno's because we didn't want staff running powershell scripts.