Outlook: removing calendar entries
We recently looked at dumping the Calendar entries
http://msmvps.com/blogs/richardsiddaway/archive/2011/08/23/outlook-viewing-calendar-entries.aspx
I usually leave entries to build up in the Calendar but a simple clean operation is to delete everything that occurred before a certain date
function remove-calendaritem {
param (
[datetime]$date
)
$outlook = New-Object -ComObject Outlook.Application
get-mailfolders |
where {$_.Path -like "*calendar*" -and $_.Path -notlike "*birthday*"} |
foreach {
$targetfolder = $outlook.Session.GetFolderFromID($_.EntryID, $_.StoreID)
$targetfolder.Items | foreach {
if ($_.StartTime -lt $date){$_.Delete()}
}
}
}
The date parameter defines the date for which we want to delete all earlier entries. Get the calendar folders and test the StartTime of each entry. If its before our date then delete it.