Page 1 of 1

ComboBox + Get-ExchangeServer = Error

Posted: Tue Feb 02, 2016 11:13 pm
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

Re: ComboBox + Get-ExchangeServer = Error

Posted: Wed Feb 03, 2016 5:24 am
by jvierra
Exchange 2010 is not compatible with PowerShell versions 3 and newer.

Re: ComboBox + Get-ExchangeServer = Error

Posted: Wed Feb 03, 2016 5:40 am
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!

Re: ComboBox + Get-ExchangeServer = Error

Posted: Wed Feb 03, 2016 5:48 am
by jvierra
I have just run it on 2010 and had no issues, Perhaps there is an error you are missing:
Try this demo:

Re: ComboBox + Get-ExchangeServer = Error

Posted: Wed Feb 03, 2016 5:52 am
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.

Re: ComboBox + Get-ExchangeServer = Error

Posted: Wed Feb 03, 2016 6:57 am
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.

Re: ComboBox + Get-ExchangeServer = Error

Posted: Thu Feb 04, 2016 10:50 pm
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.

Re: ComboBox + Get-ExchangeServer = Error

Posted: Fri Feb 05, 2016 5:00 am
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.

Re: ComboBox + Get-ExchangeServer = Error

Posted: Fri Feb 05, 2016 5:12 am
by SABeShnik
Totally agree! Check for yourself :)