Forum Discussion
PowerShell - ActiveX Control Error
- Apr 24, 2023
ColeRiese Does your script utilize any forms? (e.g. $form1 = New-Object System.Windows.Forms.Form)
I just got done going through this and was finally able to work around it. It is my understanding that there is a bug in newer versions of the Exchange Online module. If you are using any sort of forms in your script and those forms are called before you connect to Exchange Online it generates the error. If you connect to Exchange Online first, then the form is called, there is no issue.
I had to tweak our script to connect to Exchange Online first, then add a prefix to our on-prem exchange session to prevent any conflicts. Here are a couple links I found during my search that helped me track down the issue.
https://twitter.com/DanielSjoegren/status/1406954671248396292
https://www.sapien.com/forums/viewtopic.php?t=15297
https://www.sapien.com/forums/viewtopic.php?t=16213&sid=b1fcd3f71b3ada945eeb75f4dbc4490f&start=10
Hope this helps!
- ColeRieseApr 24, 2023Copper ContributorHi Harm, I am running PS version 5. Thanks!
- Apr 24, 2023
Could you run this in an admin command prompt?
powershell.exe -noprofile
update-module ExchangeOnlineManagement
connect-Exchangeonline- QuintonRDec 29, 2023Copper ContributorI had the same issue as the original post and this resolved my issue. Thank you!