Creating Outlook Calendar Appointments
$olAppointmentItem = 1
$o = new-object -comobject outlook.application
#Each new calendar appointment must have the CreateItem and Save lines
#--------One complete Calendar---------------
$a = $o.CreateItem($olAppointmentItem)
$a.Start = "2/14/2013 8:00 AM"
$a.Duration = 60
$a.Subject = "Monthly Budget Meeting"
$a.Body = "See Agenda Items at http://www.contoso.com"
$a.Location = "Finance Section"
$a.ReminderMinutesBeforeStart = 15
$a.ReminderSet = $True
$result = $a.Save()
#--------Appointment Item Entry--------------
$a = $o.CreateItem($olAppointmentItem)
$a.Start = "3/11/2013 8:00 AM"
$a.Duration = 60
$a.Subject = "Monthly Budget Meeting"
$a.Body = "See Agenda Items at http://www.contoso.com"
$a.Location = "Finance Section"
$a.ReminderMinutesBeforeStart = 15
$a.ReminderSet = $True
$result = $a.Save()
$a = $o.CreateItem($olAppointmentItem)
$a.Start = "4/18/2013 8:00 AM"
$a.Duration = 60
$a.Subject = "Monthly Budget Meeting"
$a.Body = "See Agenda Items at http://www.contoso.com"
$a.Location = "Finance Section"
$a.ReminderMinutesBeforeStart = 15
$a.ReminderSet = $True
$result = $a.Save()
#End of Script, you've now added three appointments.
#Expand to suit your needs and add/delete $a. fields as needed.
Deleting Outlook Calendar Appointments
#Connect to Outlooks Calendar Folder System
Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null
$olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
$outlook = new-object -comobject outlook.application
$namespace = $outlook.GetNameSpace("MAPI")
$folder = $namespace.getDefaultFolder($olFolders::olFolderCalendar)
#Now you can search for Calendar Objects just like any other type
#In the example below, I'm searching for entries with a
#subject of Monthly Budget Meeting that starts as of the
#current date andd time
$folder.items |?{$_.Subject -like "*Monthly Budget Meeting*" -and $_.Start -gt (get-date)}|%{$_.delete()}
#End of script. Now you know how to search and
#delete multiple appointments
No comments:
Post a Comment