Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Powershell Script error - Exchange

Posted on 2016-10-11
6
Medium Priority
?
164 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
  • 3
  • 3
6 Comments
 
LVL 41

Accepted Solution

by:
footech earned 2000 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
Technology Partners: 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 41

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 41

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

Ready for your healthcare security check-up?

In the past few years, healthcare organizations have become a prime target for advanced attacks. Does your organization have what it needs to defend itself? Schedule your healthcare security check-up today and download our free Healthcare Security Resource Kit today!

Question has a verified solution.

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

With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…
Suggested Courses
Course of the Month12 days, 5 hours left to enroll

916 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