ExchangeOnline with PowerShell 7

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
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.
This topic is 1 year and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
bgalinsky
Posts: 1
Last visit: Mon Oct 10, 2022 8:54 am

ExchangeOnline with PowerShell 7

Post by bgalinsky »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: PowerShell Studio 2022
Operating system: Windows 10,11
PowerShell version(s): 7.2.3

*** Please add details and screenshots as needed below. ***

DO NOT POST LICENSES, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM

Greetings all,

I have reviewed several posts regarding this topic. I'm posting because some of the replies appear contradictory (at least to me :? ).

My question is fairly straightforward. With the latest version of the ExchangeOnlineManagement module (version 2.0.5), can you display a form (GUI) first and then connect to ExchangeOnline (using the Connect-ExchangeOnline cmdlet)?

I have tried this and it hangs after the banner is displayed. As mentioned in other posts, this scenario described above used to work in WindowsPowerShell 5.1 with the ExchangeOnlineManagement version 2.0.3. It doesn't seem to work with any version above that. Some posts have suggested this does work with PowerShell 7.

Any guidance or clarification will be greatly appreciated.
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 3:14 pm
Answers: 39
Been upvoted: 30 times

Re: ExchangeOnline with PowerShell 7

Post by brittneyr »

[Topic moved to PowerShell GUIs forum by moderator]
Brittney
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ExchangeOnline with PowerShell 7

Post by jvierra »

Most Azure and "online" products require connection and loading of modules before you display any form. This is mostly due to the "single-threaded" nature of PowerShell. Most APIs rely on being able to control a thread completely until the connection operation is completed. Forms and GUIs tend to disrupt this and cause failures in online connective processes.

This is a condition that Microsoft has not addressed and likely won't as PowerShell was never designed to be implemented as a GUI. It can be used but certain things will not work from within a displayed form. These things can be overcome if you use a compiled program that can be multi-threaded. PowerShell cannot be multi-threaded even though we can create new threads.

My experience with the Exchange module is that it will not work correctly if it is not connected before the GUI is displayed.
This topic is 1 year and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked