Tuesday, January 26, 2016

A fun script for creating meetings in Outlook.
For the very lazy admin

function createMeeting(
    $Subject = "Test Meeting",
    $body = "Just Testing",
    $location = "Here",
    $start = "1/26/2016 12:00 PM",
    $duration = 60,
    $reminderSet = $true,
    $reminderMinutesBeforeStart = 15
    )
{
$olAppointmentItem = 1
$o = New-Object -comobject outlook.application
$a = $o.CreateItem($olAppointmentItem)
$a.MeetingStatus.olMeeting
$a.Start = $start
$a.Duration = $duration
$a.Subject = $Subject
$a.body = $body
$a.Location = $location
$a.ReminderMinutesBeforeStart = $reminderMinutesBeforeStart
$a.reminderSet = $true
$result = $a.Save()
}


$Duration = 60
$Subject = "Test1"
$Body = "testar2"
$Location="Office"
$ReminderMinutesBeforeStart = 30
$reminderSet = $true

#This scenario is set of dates with same meeting time
$arrayOfDates =  "2016-01-26", "2016-01-27","2016-01-28"
$hour = 10
$minute = 00
for ($i=0;$i -le ($ArrayOfDates.count-1);$i++) {
$dateTime = get-date $ArrayOfDates[$i] -Hour $hour -Minute $minute
$dateTime
createMeeting -Subject $Subject -body $Body -location $Location -reminderSet $reminderSet -reminderMinutesBeforeStart $ReminderMinutesBeforeStart -duration $Duration -start $dateTime
}

References:
https://social.technet.microsoft.com/Forums/windowsserver/en-US/077733c5-6e39-489e-908a-d3098c512a71/need-to-create-meeting-request-using-powershell-with-outlook-2010-2013?forum=winserverpowershell

No comments: