Forum Discussion
KathyROI
Aug 02, 2022Brass Contributor
Error 'Index was out of range. Must be non-negative and less than the size of the collection.'
I have version 2.0.6 of module ExchangeOnlineManagement installed and I am using WindowsPowerShell 5.1. I issue the following connect statement inside a script: Connect-ExchangeOnline -AppId <a...
- Aug 03, 2022
You can find a bit of running commentary about the issue here but since it's an error internal to the Connect-ExchangeOnline commandlet, there's little you can do about it directly yourself:
powershell - New-ExoPSSession: Index was out of range - Stack Overflow
I'd try the suggestion from the user "az1d" and explicitly load the module first before calling Connect-ExchangeOnline as that fits the description you've provided below where when you run the same command a second time, it works. This is because the first time you called it, it would have resulted in the implicit loading of the module first.
So, try this from a brand new PowerShell window where you haven't loaded or run anything yet:
Import-Module -Name ExchangeOnlineManagement; Connect-ExchangeOnline -Organization <blah> -AppId <blee> -CertificateThumbprint <blech>;
Cheers,
Lain
LainRobertson
Aug 03, 2022Silver Contributor
You can find a bit of running commentary about the issue here but since it's an error internal to the Connect-ExchangeOnline commandlet, there's little you can do about it directly yourself:
powershell - New-ExoPSSession: Index was out of range - Stack Overflow
I'd try the suggestion from the user "az1d" and explicitly load the module first before calling Connect-ExchangeOnline as that fits the description you've provided below where when you run the same command a second time, it works. This is because the first time you called it, it would have resulted in the implicit loading of the module first.
So, try this from a brand new PowerShell window where you haven't loaded or run anything yet:
Import-Module -Name ExchangeOnlineManagement;
Connect-ExchangeOnline -Organization <blah> -AppId <blee> -CertificateThumbprint <blech>;
Cheers,
Lain
LainRobertson
Aug 03, 2022Silver Contributor
Below is an officially-logged discussion of the same issue, though the author doesn't provide the module version they hit the issue on and the discussion itself isn't particularly informative. It's only use is confirmation of the bug.
I probably should have also suggested updating to the current module version, 2.0.5, and removing 2.0.3 if that version's not explicitly needed.
Cheers,
Lain