Solved

Powershell Script error - Exchange

Posted on 2016-10-11
6
72 Views
Last Modified: 2016-11-01
I've found this script that would enable us to input Outlook Calendar meetings into users calendars without an invite.

http://www.slipstick.com/exchange/cmdlets/use-powershell-import-appointments/

 I get an error:
 Unable to index into an object of type System.Management.Automation.PSObject.
 At D:\Program Files\Microsoft\Exchange Server\V14\Bin\Import-CalendarCSV.ps1:72 char:16
 +     if (!$CSVFile[ <<<< 1].$Key)
     + CategoryInfo          : InvalidOperation: (1:Int32) [], RuntimeException
     + FullyQualifiedErrorId : CannotIndex
0
Comment
Question by:mkllpit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 40

Accepted Solution

by:
footech earned 500 total points (awarded by participants)
ID: 41838991
The error happens when your .CSV file only has one line (besides the headers).
You can change line 60 to the following to handle it.
$CSVFile = @(Import-Csv -Path $CSVFileName);

Open in new window

0
 

Author Comment

by:mkllpit
ID: 41839013
thanks. I added a second line, and that error went away. Can you assist with these errors now?

Exception calling "LoadFile" with "1" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
At D:\Admin\Import-CalendarCSV\Import-CalendarCSV\Import-CalendarCSV.ps1:90 char:39
+  [void][Reflection.Assembly]::LoadFile <<<< ($EWSManagedApiPath);
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Performing autodiscover for sgrossman@mkllptest.com
Exception calling "AutodiscoverUrl" with "1" argument(s): "The Autodiscover service couldn't be located."
At D:\Admin\Import-CalendarCSV\Import-CalendarCSV\Import-CalendarCSV.ps1:120 char:27
+         $service.AutodiscoverUrl <<<< ($EmailAddress);
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : DotNetMethodException
0
 

Author Comment

by:mkllpit
ID: 41839028
Ok, I think I fixed the first error, just this one:

Exception calling "AutodiscoverUrl" with "1" argument(s): "The Autodiscover service couldn't be located."
At D:\Admin\Import-CalendarCSV\Import-CalendarCSV\Import-CalendarCSV.ps1:120 char:27
+         $service.AutodiscoverUrl <<<< ($EmailAddress);
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : DotNetMethodException
0
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!

 
LVL 40

Expert Comment

by:footech
ID: 41839255
I don't think I can help you on that one.   Though I do see on line 93 it appears to reference Exchange 2007.  Is that the version you're using?  If not, you might have to change the command.
https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.exchangeversion%28v=exchg.80%29.aspx?f=255&MSPPError=-2147217396
0
 

Author Comment

by:mkllpit
ID: 41839301
hmmm, good eye, we're using Exchange 2010, I'll check that. Thanks!
0
 
LVL 40

Expert Comment

by:footech
ID: 41868066
Original question was answered.
I'd suggest starting a new question for any follow up questions.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

734 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