Forum Discussion
Error 'Index was out of range. Must be non-negative and less than the size of the collection.'
- Aug 02, 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
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
Hi LainRobertson ,
I do have the Import-Module statement preceding the connect statement in my script. The article you pointed me too suggests that you should NOT execute the Import statement so I will give that a try!
Uninstall 2.0.6 version isn't working for me. Can I simply delete the 2.0.6 folder to uninstall that version? I might just keep it as someone suggested in that other article the out of range issue was introduced in 2.0.4.