Automating Outlook with Powershell (calendar)

My boss has a great technique – every day he blocks out the next business day with the calendar, so that people don’t book his time up at the last minute.

That’s not to say that important meetings can’t take place – but if it’s important people will generally come and speak to you. Essentially, it filters out the people who haven’t planned ahead and want to bring people together for (often pointless or unplanned) meetings.

I love this idea – now that I manage my calendar is pretty full, and I do really value keeping some time at my desk and with the team, so I can stay on top of what is happening and being available for them.

And of course – I love to automate everything. So this is my simple powershell script that runs at 3am every day and books my time out for the next business day.

 
$outlookApplication = New-Object -ComObject 'Outlook.Application'
 
$d = [DateTime]::Now.AddDays(1); while ($d.DayOfWeek -eq "Saturday" -or $d.DayOfWeek -eq "Sunday") { $d = $d.AddDays(1) }; $d
 
$appt = $outlookApplication.CreateItem('olAppointmentItem')
$appt.Start = $d; # next business day
$appt.AllDayEvent = $true;
$appt.Subject = "Time Block"
$appt.Categories = "Admin Time"
$appt.BusyStatus = 1 # == olTentative;, 2 for busy
$appt.ReminderSet = $false;
 
$appt.Save()

Leave a Reply

Your email address will not be published.