Last active
October 31, 2016 10:43
-
-
Save jacobludriks/8cdd5c2a74d70fd35b3b to your computer and use it in GitHub Desktop.
meetingroomutilization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$startTime = (Get-Date -Hour 00 -Minute 00 -Second 00 -Day 01 -Month 07 -Year 2013) | |
$endTime = (Get-Date -Hour 00 -Minute 00 -Second 00 -Day 01 -Month 07 -Year 2014) | |
$exportFile = "C:\temp\calendar-export.csv" | |
$outlook = new-object -com outlook.application; | |
$mapi = $outlook.GetNameSpace("MAPI"); | |
$mailboxlist = $mapi.Folders | |
foreach ($mailbox in $mailboxlist) { | |
$MailboxName = $mailbox.Name | |
if ($mailboxname -notlike 'Mailbox -*' -and $mailboxname -notlike 'Personal*') { | |
write-host $MailboxName -ForegroundColor Red | |
if ($mailbox.Folders.Item("Calendar").Items) { | |
write-host "Found calendar - exporting items..." | |
$calitems = $mailbox.Folders.Item("Calendar").Items | |
$calItems.Sort("[Start]") | |
$calItems.IncludeRecurrences = $true | |
$dateRange = "[End] >= '{0}' AND [Start] <= '{1}'" -f $startTime.ToString("g"), $endTime.ToString("g") | |
$calExport = $calItems.Restrict($dateRange) | |
$calCombined += $calExport | select @{Name='MeetingRoom';Expression={$mailboxname}}, Subject, StartUTC, EndUTC, Duration, Organizer, RequiredAttendees, IsRecurring | |
} | |
} | |
} | |
$calCombined | select MeetingRoom, Subject, StartUTC, EndUTC, Duration, Organizer, RequiredAttendees, IsRecurring | sort MeetingRoom,StartUTC -Descending | Export-Csv $exportFile -NoType |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment