Solved

Import multiple appointments into O365 calendar

Posted on 2015-02-22
18
610 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 94

Expert Comment

by:John Hurst
ID: 40624138
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
ID: 40624194
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 40

Assisted Solution

by:Vasil Michev (MVP)
Vasil Michev (MVP) earned 500 total points
ID: 40624631
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 2

Author Comment

by:heensit
ID: 40625205
Hi Vasil,

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

Expert Comment

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

Author Comment

by:heensit
ID: 40625220
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 40

Expert Comment

by:Vasil Michev (MVP)
ID: 40625223
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
ID: 40654538
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 40

Expert Comment

by:Vasil Michev (MVP)
ID: 40654582
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
 
LVL 2

Author Comment

by:heensit
ID: 40654618
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 40

Assisted Solution

by:Vasil Michev (MVP)
Vasil Michev (MVP) earned 500 total points
ID: 40654638
0
 
LVL 2

Author Comment

by:heensit
ID: 40654657
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 40

Assisted Solution

by:Vasil Michev (MVP)
Vasil Michev (MVP) earned 500 total points
ID: 40654710
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
ID: 40654808
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
ID: 40654809
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
ID: 40654876
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 40

Accepted Solution

by:
Vasil Michev (MVP) earned 500 total points
ID: 40654985
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
ID: 40655074
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

680 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