Import multiple appointments into O365 calendar

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
LVL 2
Filip HeensAsked:
Who is Participating?
 
Vasil Michev (MVP)Connect With a Mentor Commented:
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
 
JohnBusiness Consultant (Owner)Commented:
Where are you importing from?  If I import calendar entries from more than one PST file, I will get all the calendar entries.
0
 
Filip HeensAuthor Commented:
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
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
Vasil Michev (MVP)Connect With a Mentor Commented:
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
 
Filip HeensAuthor Commented:
Hi Vasil,

Do you mean you cannot import PST or, you cannot import at all?
0
 
Vasil Michev (MVP)Commented:
You can import PSTs, just not with PowerShell.
0
 
Filip HeensAuthor Commented:
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
 
Vasil Michev (MVP)Commented:
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
 
Filip HeensAuthor Commented:
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
 
Vasil Michev (MVP)Commented:
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
 
Filip HeensAuthor Commented:
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
 
Vasil Michev (MVP)Connect With a Mentor Commented:
0
 
Filip HeensAuthor Commented:
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
 
Vasil Michev (MVP)Connect With a Mentor Commented:
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
 
Filip HeensAuthor Commented:
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
 
Filip HeensAuthor Commented:
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
 
Filip HeensAuthor Commented:
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
 
Filip HeensAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.