Advertisement
Guest User

Powershell: Export Outlook calendar to .ics

a guest
Aug 20th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Add-Type -AssemblyName microsoft.office.interop.outlook
  2. $olFolders = “Microsoft.Office.Interop.Outlook.OlDefaultFolders” -as [type]
  3. $olCalendarDetail = “Microsoft.Office.Interop.Outlook.olCalendarDetail” -as [type]
  4. $olCalendarMailFormat = “Microsoft.Office.Interop.Outlook.olCalendarMailFormat” -as [type]
  5. $outlook = New-Object -ComObject outlook.application
  6. $namespace = $Outlook.GetNameSpace(“mapi”)
  7. $folder = $namespace.getDefaultFolder($olFolders::olFolderCalendar)
  8. $CalendarSharing=$folder.GetCalendarExporter()
  9. $CalendarSharing.CalendarDetail = $olCalendarDetail::olFullDetails
  10. $CalendarSharing.startDate = (Get-Date).addDays(-30)
  11. $CalendarSharing.endDate = (Get-Date).addDays(365)
  12. $CalendarSharing.RestrictToWorkingHours = $false
  13. $CalendarSharing.IncludeAttachments = $false
  14. $CalendarSharing.IncludePrivateDetails = $true
  15. $MailItem = $CalendarSharing.SaveAsICal(“\\myserver.mydomain.local\MyShare\MyOutlook.ics”)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement