Hello
I ask the question again because i still have this exact problem described in "Connect-ExchangeOnline doesn't bring up MFA Capable browser based logonbox when executed from PowerShell Studio GUI"
I have tried all what was described even with PWS V7 with no success
I am unable to lauch a powershellStudio project with forms if i call connect-exchangeonline
I just want to add an information :
if i call connect-msolservice all is working perfectly. (i use the same MFA user !)
The problem occurs only when calling connect-exchangeonline
I am really disappointed because i only use powershell studio for some basic GUI for Office 365 actions
Thank's in advance for yours answers
NEW Connect-ExchangeOnline doesn't bring up MFA Capable browser based logonbox when executed from PowerShell Studio GUI
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: NEW Connect-ExchangeOnline doesn't bring up MFA Capable browser based logonbox when executed from PowerShell Studio
I have found a workaround :
Install PowerShell Exchange Online Module from Exchange Management interface (hybrid section)
Then use this instead of connect-exchangeonline :
$MFAExchangeModule = (Get-ChildItem -Path $($env:LOCALAPPDATA + "\Apps\2.0\") -Filter CreateExoPSSession.ps1 -Recurse).FullName | select-object -last 1
. "$MFAExchangeModule"
connect-exopssession
For information : connect-exchangeonline works like a charm if the project is a simple powershellstudio script project (instead of being a Form project)
if any has a better idea....
Install PowerShell Exchange Online Module from Exchange Management interface (hybrid section)
Then use this instead of connect-exchangeonline :
$MFAExchangeModule = (Get-ChildItem -Path $($env:LOCALAPPDATA + "\Apps\2.0\") -Filter CreateExoPSSession.ps1 -Recurse).FullName | select-object -last 1
. "$MFAExchangeModule"
connect-exopssession
For information : connect-exchangeonline works like a charm if the project is a simple powershellstudio script project (instead of being a Form project)
if any has a better idea....
Re: NEW Connect-ExchangeOnline doesn't bring up MFA Capable browser based logonbox when executed from PowerShell Studio
Here is a simple example of it working/breaking (at lease for me in my environment).
In WPS 5.1 this works:
Connect-ExchangeOnline
Add-Type -AssemblyName System.Windows.Forms
$FormMain = New-Object System.Windows.Forms.Form
$FormMain.ShowDialog()
$FormMain.Dispose()
Note that Connect-ExchangeOnline is called BEFORE the New-Object. This allows the MFA (GUI) prompt to show up.
If I switch it to this example below instead, it never shows MFA (GUI) prompt (it just hangs):
Add-Type -AssemblyName System.Windows.Forms
$FormMain = New-Object System.Windows.Forms.Form
Connect-ExchangeOnline
$FormMain.ShowDialog()
$FormMain.Dispose()
Note that Connect-ExchangeOnline is called AFTER the New-Object. This hangs the MFA (GUI) prompt.
With PS 7, the MFA GUI prompt is replaced with a web-browser based MFA login (at least for me it does). In this case, either of the above examples work. Its only with WPS 5.1 does the second example fail.
Additionally, this only happens with the newer version of the Exchange module, where they added support for PS7. So whatever they did to make it work with PS7, I am guessing is what is also causing the new problem with WPS 5.1
One final note, if you cancel ANY of the MFA login prompts, it also seems to cause problems. So if you are testing the above, and cancel the MFA login process, you may not see the form or it may hang. You need to SUCCESSFULLY login to MFA to get a working example, from the above code. In my production code, I handle this with TRY/CATCH etc., which I have excluded in the above examples.
Hope this helps.
NK
In WPS 5.1 this works:
Connect-ExchangeOnline
Add-Type -AssemblyName System.Windows.Forms
$FormMain = New-Object System.Windows.Forms.Form
$FormMain.ShowDialog()
$FormMain.Dispose()
Note that Connect-ExchangeOnline is called BEFORE the New-Object. This allows the MFA (GUI) prompt to show up.
If I switch it to this example below instead, it never shows MFA (GUI) prompt (it just hangs):
Add-Type -AssemblyName System.Windows.Forms
$FormMain = New-Object System.Windows.Forms.Form
Connect-ExchangeOnline
$FormMain.ShowDialog()
$FormMain.Dispose()
Note that Connect-ExchangeOnline is called AFTER the New-Object. This hangs the MFA (GUI) prompt.
With PS 7, the MFA GUI prompt is replaced with a web-browser based MFA login (at least for me it does). In this case, either of the above examples work. Its only with WPS 5.1 does the second example fail.
Additionally, this only happens with the newer version of the Exchange module, where they added support for PS7. So whatever they did to make it work with PS7, I am guessing is what is also causing the new problem with WPS 5.1
One final note, if you cancel ANY of the MFA login prompts, it also seems to cause problems. So if you are testing the above, and cancel the MFA login process, you may not see the form or it may hang. You need to SUCCESSFULLY login to MFA to get a working example, from the above code. In my production code, I handle this with TRY/CATCH etc., which I have excluded in the above examples.
Hope this helps.
NK
Re: NEW Connect-ExchangeOnline doesn't bring up MFA Capable browser based logonbox when executed from PowerShell Studio
thank's a lot for your answer !!
I never went to the "source" script file !
i now understand better your comment about New-Object 'System.Windows.Forms.Form' and the order actions (connect-exchangeonline before the forms command)
When i have read your comments in the first post i didn't realize that, because i was only using the script editor given by sapien which does not show the exact content (to simplify)
i will try
Again thank's !
Phil
I never went to the "source" script file !
i now understand better your comment about New-Object 'System.Windows.Forms.Form' and the order actions (connect-exchangeonline before the forms command)
When i have read your comments in the first post i didn't realize that, because i was only using the script editor given by sapien which does not show the exact content (to simplify)
i will try
Again thank's !
Phil