Windows Form Message Box Anomaly

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

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 3 years and 4 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.
User avatar
gareth.jacobs
Posts: 34
Last visit: Wed Jan 24, 2024 7:43 pm

Windows Form Message Box Anomaly

Post by gareth.jacobs »

Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.181
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19041.0

I created a Windows Form project. In it, the O365 function Get-EXOMailbox is called and returns a value to a variable as expected. However, a Windows form messagebox is also splashed with the message "Count of Objects Returned: 1". If a loop calls Get-EXOMailbox 200 times, 200 messages are splashed and cannot be cleared until the loop ends. (See attachment).

I can find no way to suppress this message box. None of the standard methods seem to work or, if they do, also prevent Get-EXOMailbox returning any data.

For example, the script authenticates to O365 using Connect-ExchangeOnline, and is executed as follows:
  1. Import-Module ExchangeOnlineManagement
  2. Connect-ExchangeOnline -UserPrincipalName $UPN -ShowProgress $true -Credential $O365Credentials
  3. $entry = Get-EXOMailbox smithj | Select DisplayName, GrantSendOnBehalfTo, RecipientTypeDetails
The $entry variable contains the expected results. When run as a Windows Form, the additional message box (below) is also displayed.

If I package the script to an .EXE or export the Form Project and run it as a script in PowerShell_ISE, the additional message box is NOT produced. It only occurs running inside the PowerShell Studio IDE using Run or Debug Run.
Attachments
Get-EXOMailbox.jpg
Get-EXOMailbox.jpg (12.68 KiB) Viewed 1176 times
User avatar
brittneyr
Site Admin
Posts: 1655
Last visit: Thu Mar 28, 2024 7:24 am
Answers: 39
Been upvoted: 30 times

Re: Windows Form Message Box Anomaly

Post by brittneyr »

This message is generated by PowerShell. From my understanding, we do not suppress any output from PowerShell. I'll talk to the development team and get back to you. In the meantime, please try adding the following line to your script:

Code: Select all

$ProgressPreference = 'SilentlyContinue'
Brittney
SAPIEN Technologies, Inc.
User avatar
gareth.jacobs
Posts: 34
Last visit: Wed Jan 24, 2024 7:43 pm

Re: Windows Form Message Box Anomaly

Post by gareth.jacobs »

brittneyr wrote: Tue Oct 27, 2020 7:43 am This message is generated by PowerShell. From my understanding, we do not suppress any output from PowerShell. I'll talk to the development team and get back to you. In the meantime, please try adding the following line to your script:

Code: Select all

$ProgressPreference = 'SilentlyContinue'
That did it. I placed it in my Globals file and the message no longer appears. It was interesting that it only happened in the PS GUI.

You learn something new everyday!

Thanks
G
This topic is 3 years and 4 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.