Solved

Import multiple appointments into O365 calendar

Posted on 2015-02-22
18
466 Views
Last Modified: 2015-03-09
Hi, does anybody got an idea (and preferably an example as I'm not a real programmer ;-))
On how to import calendar items into O365 mailboxes?

I've found a lot of articles on how to do it on an Exchange sever but as the servers are in the cloud that won't work :( ;-)

Thanks in advance
0
Comment
Question by:heensit
  • 10
  • 7
18 Comments
 
LVL 90

Expert Comment

by:John Hurst
Comment Utility
Where are you importing from?  If I import calendar entries from more than one PST file, I will get all the calendar entries.
0
 
LVL 2

Author Comment

by:heensit
Comment Utility
Sorry I seem to have forgotten that I need to import it via powershell...

I need to import in multiple mailboxes (so preferably via powershell) and I didn't know I could import pst's via powershell...
I know I can do it via the import in Outlook, but if you have to do over 50 mailboxes... ;-)
0
 
LVL 38

Assisted Solution

by:Vasil Michev (MVP)
Vasil Michev (MVP) earned 500 total points
Comment Utility
You cannot import via PowerShell in Exchange Online/Office 365. You will have to either use Outlook, some EWS script, or additional software. The PST capture tool for example: https://technet.microsoft.com/en-us/library/hh781036(v=exchg.141).aspx. Or 3rd party tools, but they come at a price.
0
 
LVL 2

Author Comment

by:heensit
Comment Utility
Hi Vasil,

Do you mean you cannot import PST or, you cannot import at all?
0
 
LVL 38

Expert Comment

by:Vasil Michev (MVP)
Comment Utility
You can import PSTs, just not with PowerShell.
0
 
LVL 2

Author Comment

by:heensit
Comment Utility
ok, but if we can do the calendar import via CSV and powershell that would be much easier... isn't that an option? or can't you import CSV into O365 via powershell?
I've looked into this
http://blogs.msdn.com/b/emeamsgdev/archive/2012/02/13/exchange-2007-2010-powershell-import-calendar-items-from-csv-file.aspx
and
http://www.slipstick.com/exchange/cmdlets/use-powershell-import-appointments/
But it wouldn't work (as I said, I'm not a real programmer ;-) )
0
 
LVL 38

Expert Comment

by:Vasil Michev (MVP)
Comment Utility
That script uses EWS, in order to make it work for Exchange Online you will need to download and install the EWS API, edit the script to use the EO EWS endpoint and either use impersonate or grant yourself full access permissions to all mailboxes. Also, it uses CSV files, not real PSTs. So, possible, but not that easy when you are using those things for the first time. If you only have few users to update just use Outlook to upload the PSTs.
0
 
LVL 2

Author Comment

by:heensit
Comment Utility
Even with EWS installed it doesn't seem to work :(

Exception calling "Bind" with "2" argument(s): "The request failed. The remote server returned an error: (401) Unauthorized."
At Import-CalendarCSV.ps1:147 char:2
+     $CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($s ...
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ServiceRequestException

although I have impersonate rights or I try it with a global admin user who has rights to that user...
Maybe it isn't support on O365?
0
 
LVL 38

Expert Comment

by:Vasil Michev (MVP)
Comment Utility
The script will not work out of the box, as I mentioned above you need to edit the EWS endpoint, i.e. the 'connect' part. Even if you do so, all the script does is to import items based on a CSV file, not PSTs.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Author Comment

by:heensit
Comment Utility
I know that it imports from csv, that why I have an csv ;-)
and as for the connect part, this is what I'm using

Get-PSSession | Remove-PSSession
Set-ExecutionPolicy Unrestricted
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session  -AllowClobber
Connect-MsolService -Credential $LiveCred

the EWS is installed

and the string I use is
.\Import-CalendarCSV.ps1 -CSVFileName calendar.csv -EmailAddress user@domain.be -Impersonate $true -EwsUrl https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml
0
 
LVL 38

Assisted Solution

by:Vasil Michev (MVP)
Vasil Michev (MVP) earned 500 total points
Comment Utility
0
 
LVL 2

Author Comment

by:heensit
Comment Utility
keep getting the same error with or without the impersonate

Exception calling "Bind" with "2" argument(s): "The request failed. The remote server returned an error: (401
) Unauthorized."
At Import-CalendarCSV.ps1:148 char:2
+     $CalendarFolder = [Microsoft.Exchange.WebServices.Data.CalendarFolder]::Bind($s ...
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ServiceRequestException

Now I use the string
.\Import-CalendarCSV.ps1 -CSVFileName calendarOTC.csv -EmailAddress user@domain.be  -EwsUrl https://outlook.office365.com/EWS/Exchange.asmx
0
 
LVL 38

Assisted Solution

by:Vasil Michev (MVP)
Vasil Michev (MVP) earned 500 total points
Comment Utility
The problem is that you are not providing any sort of credentials. The script is intended to be run from a local connection, where UseDefaultCredentials has a value. In your case, you need to specify the Username and Password for the account with Impersonate or Full Access permissions
0
 
LVL 2

Author Comment

by:heensit
Comment Utility
Vasil, can I send you the script? then you can look at it, as I AM providing the username and password via the
Get-PSSession | Remove-PSSession
Set-ExecutionPolicy Unrestricted
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session  -AllowClobber
Connect-MsolService -Credential $LiveCred
PS I DO appreciate your help
0
 
LVL 2

Author Comment

by:heensit
Comment Utility
Wait, I thing I understand what you mean ;-)
(:()
just found this in the script

 if ($Username -and $Password)
 {
     if ($Domain)
     {
         $service.Credentials = New-Object  Microsoft.Exchange.WebServices.Data.WebCredentials($Username,$Password,$Domain);
     } else {
         $service.Credentials = New-Object  Microsoft.Exchange.WebServices.Data.WebCredentials($Username,$Password);
     }
     
} else {
     $service.UseDefaultCredentials = $true;
 }
0
 
LVL 2

Author Comment

by:heensit
Comment Utility
I'm doing something wrong I guess ;-)
First I'm asking for username and password
$Username = Read-Host -Prompt "Enter username with Impersonate credentials"
$SecurePassword = Read-Host -Prompt "Enter password" -AsSecureString
then I make a O365 connection
$LiveCred = New-Object System.Management.Automation.PSCredential($Username,$SecurePassword)
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session  -AllowClobber
Connect-MsolService -Credential $LiveCred

That works fine

and then I try to create the service object
         $service.Credentials = New-Object  Microsoft.Exchange.WebServices.Data.WebCredentials($Username,$SecurePassword);
but that doesn't seem to work as I keep getting
Exception calling "Bind" with "2" argument(s): "The request failed. The remote server returned an error: (401) Unauthorized."
0
 
LVL 38

Accepted Solution

by:
Vasil Michev (MVP) earned 500 total points
Comment Utility
Just use the relevant script parameters:

.\Import-CalendarCSV.ps1 -EmailAddress user@domain.onmicrosoft.com -CSVFileName 'blabla' -EWSManagedApiPath "blabla" -EwsUrl https://outlook.office365.com/EWS/Exchange.asmx -Username admin@domain.com -Password Password123

Open in new window

0
 
LVL 2

Author Closing Comment

by:heensit
Comment Utility
First part is working now :D
it's creating all day events though, but that something for another question, I'm also going to try to get it to go through ALL mailboxes ;-)
0

Featured Post

Too many email signature updates to deal with?

Do you feel like you are taking up all of your time constantly visiting users’ desks to make changes to email signatures? Wish you could manage all signatures from one central location, easily design them and deploy them quickly to users? Well, there is an easy way!

Join & Write a Comment

Outlook Free & Paid Tools
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now