Exchange Online connection freeze GUI

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 11 months and 2 weeks 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
User avatar
Mekac_CZ
Posts: 9
Last visit: Fri May 19, 2023 6:13 am

Exchange Online connection freeze GUI

Post by Mekac_CZ »

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: PowerShell Studio 2021 (64 Bit)
Build: v5.8.187
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19044.0

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

Hello,
in GUI i cant connect to Exchange Online management. The GUI always freeze.

$form1_Load={
#TODO: Initialize Form Controls here
$connectsplat = @{
Organization = "mycompany.onmicrosoft.com"
AppId = "1234abdf-94d8-4339-979f-96fb18f48e97"
CertificateThumbprint = "421162ed1d6a176ceb2d15128159b24f4163423e" # certificate thumbprint

}
#>
Connect-ExchangeOnline @connectsplat -verbose
}

>> Platform: V5 64Bit (STA) (Forced)
VERBOSE: ExchangeEnvironment : O365Default
VERBOSE: ConnectionUri :
VERBOSE: AzureADAuthorizationEndpointUri :
VERBOSE: DelegatedOrganization :
VERBOSE: Prefix :
VERBOSE: FormatTypeName :*
VERBOSE: CommandName :*
VERBOSE: Importing cmdlet 'Add-EXOClientTelemetryWrapper'.
VERBOSE: Importing cmdlet 'New-EXOClientTelemetryFilepath'.
VERBOSE: Importing cmdlet 'Push-EXOTelemetryRecord'.
VERBOSE: Importing cmdlet 'Clear-ActiveToken'.
VERBOSE: Importing cmdlet 'New-ExoPSSession'.
VERBOSE: Importing cmdlet 'Test-ActiveToken'.
.. and hangs

Within powershell_ise / normal console the connection works.
by Alexander Riedel » Sun Apr 09, 2023 9:31 am
There are a couple of posts about this already here on this forum where you can find more details.
The gist is that the Windows Forms threading model and the Microsoft Exchange PowerShell module are not compatible.
Generally the consensus is that you need to establish this connection before you initialize your form.
Go to full post
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Exchange Online connection freeze GUI

Post by Alexander Riedel »

There are a couple of posts about this already here on this forum where you can find more details.
The gist is that the Windows Forms threading model and the Microsoft Exchange PowerShell module are not compatible.
Generally the consensus is that you need to establish this connection before you initialize your form.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 11 months and 2 weeks 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