ComboBox + Get-ExchangeServer = Error

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 8 years and 1 month 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
SABeShnik
Posts: 13
Last visit: Wed Nov 16, 2016 3:25 am

ComboBox + Get-ExchangeServer = Error

Post by SABeShnik »

Hi PowerHell guys!

Indicated at the beginning of the script : Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Get error when using ComboBox with Exchnage cmdlet "Get-ExchangeServer":
CMDLine:
Load-ComboBox $combobox_ServerName (Get-ExchangeServer | ? { $_.ServerRole -ne 'EDGE' }) -DisplayMember "Name"
"The term 'get-ExchangeServer' is not recognized as the name of cmdelt ....."

Other Exchange CMDLets works good :?:

Help, please
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ComboBox + Get-ExchangeServer = Error

Post by jvierra »

Exchange 2010 is not compatible with PowerShell versions 3 and newer.
User avatar
SABeShnik
Posts: 13
Last visit: Wed Nov 16, 2016 3:25 am

Re: ComboBox + Get-ExchangeServer = Error

Post by SABeShnik »

jvierra wrote:Exchange 2010 is not compatible with PowerShell versions 3 and newer.
Hi jvierra!
Thank you for joining to solve my problem!
I used this on Exchange 2013 servers - the problem is the same: "is not recognized cmdlet ....".
If use the Exchange 2013 cmdlets without Combobox - all works.

If i don't use Combobox - Exchange 2013 cmdlets are working good. :)
If i use Combobox - Exchange 2013 cmdlets are not working! :( Why?

Thanks in advance!
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ComboBox + Get-ExchangeServer = Error

Post by jvierra »

I have just run it on 2010 and had no issues, Perhaps there is an error you are missing:
Try this demo:
Attachments
Demo-Exchange.psf
(24.78 KiB) Downloaded 198 times
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ComboBox + Get-ExchangeServer = Error

Post by jvierra »

Servers that are running the following applications can now run WMF 4.0. The versions listed are the minimum releases required to run WMF 4.0. •Microsoft Exchange Server 2013 Service Pack 1
•Microsoft Exchange Server 2010 SP3 with Update Rollup 5
•Microsoft SharePoint Server 2013 Service Pack 1
•Microsoft SharePoint Server 2010 with the February 2014 Cumulative Update

2010 and 2013 must still run snap-in under PowersShell 2 and 2 must be separately enabled in Server manager.

If you are running this on W7 or later with client tools then you may need other patches.
User avatar
SABeShnik
Posts: 13
Last visit: Wed Nov 16, 2016 3:25 am

Re: ComboBox + Get-ExchangeServer = Error

Post by SABeShnik »

jvierra, as soon as you came in the post - almost immediately it worked :) :!: Thank you.
A little later I will describe here in detail.
User avatar
SABeShnik
Posts: 13
Last visit: Wed Nov 16, 2016 3:25 am

Re: ComboBox + Get-ExchangeServer = Error

Post by SABeShnik »

Hi PowerShell guys!

When i add a Combobox on the form is automatically added PowerShell function "Load-ComboBox". I think the problem was in this PowerShell function.
1. Deleted it and all the Comboboxes, then added them again;
2. "Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010" moved from "$OnLoadFormEvent={}" below.
After that when using the Combobox "... is not recognized cmdlet..." error disappeared.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: ComboBox + Get-ExchangeServer = Error

Post by jvierra »

Yes - this can happen if you accidently delete two syntax delimiters in such a way that the code parser does not detect the it as an error. This will make the code behave in odd ways.

When you have a problematic issue like this try starting a new form or script with only the minimum items needed to test the suspect lines. This can help to determine if it is broken code or, perhaps a hard to see coding mistake.
User avatar
SABeShnik
Posts: 13
Last visit: Wed Nov 16, 2016 3:25 am

Re: ComboBox + Get-ExchangeServer = Error

Post by SABeShnik »

Totally agree! Check for yourself :)
This topic is 8 years and 1 month 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