{"id":2842,"date":"2016-11-13T18:36:35","date_gmt":"2016-11-13T16:36:35","guid":{"rendered":"http:\/\/9v.lt\/blog\/?p=2842"},"modified":"2022-01-19T08:34:36","modified_gmt":"2022-01-19T06:34:36","slug":"synchronizing-office365-calendars-web","status":"publish","type":"post","link":"https:\/\/9v.lt\/blog\/synchronizing-office365-calendars-web\/","title":{"rendered":"Synchronizing Office365 calendars with the web"},"content":{"rendered":"<p>Hello. Today I&#8217;m writing about a different version of a powershell utility script <a href=\"http:\/\/9v.lt\/blog\/synchronizing-exchange-calendars-with-the-web\/\" target=\"_blank\" rel=\"noopener noreferrer\">I made before for calendar synchronization<\/a>. See that post for details and bottom of it for a raging update. This is a continued post from before.<br \/>\nThat script I made before was for an Exchange server and it was working great at the time. But later we switched to Office365 and since April it became broken in a way that was making me wanna pull my hair out. However thanks to my persistence and a nudge into the right direction from some people just when I was about to give up, I was able to make that script work again, so in turn I made it as a different script and named it v2. The old one can still be found <a href=\"http:\/\/9v.lt\/projects\/powershell\/importCalCsv.ps1\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<br \/>\n<!--more--><br \/>\nNow the thing here to understand, is that O365 cloud is great, it offers lots of awesome things. But if you&#8217;re an administrator who wants to automate some stuff and need to dig deeper into the core of it all, then prepare for a world of pain.<br \/>\nDon&#8217;t get me wrong though &#8211; the API docs are good enough for general purpose coding tasks and there are many good code samples to learn from, but some specific things lack documentation and here I&#8217;ll describe how I made my script work again. Read <a href=\"http:\/\/9v.lt\/blog\/synchronizing-exchange-calendars-with-the-web\/\" target=\"_blank\" rel=\"noopener noreferrer\">the first post<\/a> for a detailed problem description.<\/p>\n<p>The new script can be found <a href=\"http:\/\/9v.lt\/projects\/powershell\/importCalCsv_v2.ps1\" target=\"_blank\" rel=\"noopener noreferrer\">in my projects folder, here<\/a>.<\/p>\n<p>For the modification reference, I used the unofficial microsoft <a href=\"https:\/\/gallery.technet.microsoft.com\/office\/Create-Appointments-for-779b55ad\" target=\"_blank\" rel=\"noopener noreferrer\">script for calendar synchronization<\/a>.<\/p>\n<p>Now what did I change exactly to make it work again? just a few things.<\/p>\n<p>The first thing you&#8217;ll notice is that you need to provide credentials now. The next thing is a callback for redirection URL validation. That block is needed for AutodiscoverUrl() and Exchange schema version was also changed to &#8220;Exchange2010_SP2&#8221;. After that, appointment logic is left as it was, but at the very end where it saves an appointment, &#8220;[Microsoft.Exchange.WebServices.Data.SendInvitationsMode]::SendToNone&#8221; attribute had to be added, otherwise the script wouldn&#8217;t work. Now this is the most interesting part, because that parameter is optional in the .Save() function, however if you don&#8217;t provide that parameter, then it won&#8217;t work &#8211; it has to be there.<\/p>\n<p>And that is pretty much it &#8211; just these few things had to be added&#8230; after 2 weeks of live testing, it all seems to be working great.<\/p>\n<p><strong>UPDATE 2017.05.01:<\/strong> I have optimized this script a a bit. Somehow I didn&#8217;t think to make the script get all appointments from the calendar when checking for changes, and not get one item at a time. This reduced the script execution time (in my case) from over 2 hours to mere 4 minutes &#8211; DAYUM suhn!<\/p>\n<p><img decoding=\"async\" width=\"250px\" src=\"\/blog\/filemgmt\/uploads\/ivairios\/WDBerBB.png\" alt=\"\" \/><\/p>\n<p>https:\/\/www.youtube.com\/watch?v=hsBW247eBi4<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello. Today I&#8217;m writing about a different version of a powershell utility script I made<\/p>\n","protected":false},"author":2,"featured_media":2844,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,750],"tags":[963,965,964,949],"class_list":["post-2842","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects","category-software-projects","tag-calendar","tag-o365","tag-office365","tag-powershell"],"_links":{"self":[{"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/posts\/2842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/comments?post=2842"}],"version-history":[{"count":0,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/posts\/2842\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/media\/2844"}],"wp:attachment":[{"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/media?parent=2842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/categories?post=2842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/9v.lt\/blog\/wp-json\/wp\/v2\/tags?post=2842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}