Support Forums

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.
User avatar
SABeShnik
Posts: 12
Joined: Wed Jan 27, 2016 1:53 pm

ComboBox + Get-ExchangeServer = Error

Postby SABeShnik » Tue Feb 02, 2016 11:13 pm

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
User avatar
jvierra
Posts: 9738
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ComboBox + Get-ExchangeServer = Error

Postby jvierra » Wed Feb 03, 2016 5:24 am

Exchange 2010 is not compatible with PowerShell versions 3 and newer.
User avatar
SABeShnik
Posts: 12
Joined: Wed Jan 27, 2016 1:53 pm

Re: ComboBox + Get-ExchangeServer = Error

Postby SABeShnik » Wed Feb 03, 2016 5:40 am

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!
User avatar
jvierra
Posts: 9738
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ComboBox + Get-ExchangeServer = Error

Postby jvierra » Wed Feb 03, 2016 5:48 am

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 62 times
User avatar
jvierra
Posts: 9738
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ComboBox + Get-ExchangeServer = Error

Postby jvierra » Wed Feb 03, 2016 5:52 am

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: 12
Joined: Wed Jan 27, 2016 1:53 pm

Re: ComboBox + Get-ExchangeServer = Error

Postby SABeShnik » Wed Feb 03, 2016 6:57 am

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: 12
Joined: Wed Jan 27, 2016 1:53 pm

Re: ComboBox + Get-ExchangeServer = Error

Postby SABeShnik » Thu Feb 04, 2016 10:50 pm

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.
User avatar
jvierra
Posts: 9738
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: ComboBox + Get-ExchangeServer = Error

Postby jvierra » Fri Feb 05, 2016 5:00 am

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: 12
Joined: Wed Jan 27, 2016 1:53 pm

Re: ComboBox + Get-ExchangeServer = Error

Postby SABeShnik » Fri Feb 05, 2016 5:12 am

Totally agree! Check for yourself :)

Return to “PowerShell GUIs”

Who is online

Users browsing this forum: No registered users and 4 guests