What am I doing wrong ?

May 15, 2013 at 3:05 PM
I've "installed" the ShowUI module, and tried some of the examples trying to get familiar with it, but none of them actually work as advertised. What's going on ? I'm running powershell with -STA, tried elevated aswell, but even something simple as this example:
$pr=StackPanel -ControlName "Prompt" -Margin "8,0,8,8" {
Label "Please Enter Your Full Name:"
StackPanel -Orientation Horizontal {
    TextBox -Name FullName -Width 100
    Button "OK" -IsDefault -Width 50 -Margin "8,0,0,0" -On_Click { 
        Set-UIValue $Prompt -Passthru | Close-Control
    }
}
} -On_Loaded { $FullName.Focus() } -Show

$pr

already fails because when I write text, hitting enter or pressing OK-button it just sits there. If I close the window, it returns nothing...
The alternative example of this:
$pr=StackPanel -ControlName "Prompt" -Margin "8,0,8,8" {
Label "Please Enter Your Full Name:"
StackPanel -Orientation Horizontal {
    TextBox -Name FullName -Width 100
    Button "OK" -IsDefault -Width 50 -Margin "8,0,0,0" -On_Click { 
        $Prompt.Tag = $FullName.Text
        $Window.Close()
    }
}
} -On_Loaded { $FullName.Focus() } -Show

$pr

works, but delivers an error:
Error in On_Click Event Handler on Button
At line:7 char:13
  • $Prompt.Tag = $FullName.Text
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Property 'Tag' cannot be found on this object; make sure it exists and is settable.
Running on Windows Server 2012 standard with powershell 3.0

I also tried powershell.exe -STA -version 2, but that even gives me more errors
So, did I install it wrong, or is ShowUI not entirely compatible with powershell 3 ?
Coordinator
May 17, 2013 at 9:46 PM
Hopefully someone can post a reply to this before I can, but if not, I'll get you an answer tomorrow night (I only have internet for a minute at a time right now, so I'm just queueing this, and I'll come back Friday).
Coordinator
May 19, 2013 at 5:59 AM
ShowUI 1.4 is compatible with PowerShell 3 (in fact, that's really the only reason we released a 1.4). PowerShell 3 runs in -STA mode by default (yay!) and ShowUI definitely does not require elevation.

Both of your examples are working fine for me here. Your first example should definitely NOT return anything if you just close the window (that's like hitting Cancel), but otherwise, because you put -IsDefault on the OK button, pressing enter is like clicking that button, and will trigger it's On_Click event handler.

There seems to be something weird going on which is causing the $Prompt variable to not be set for you, which would break both of those examples.

Can you check two things:
  1. Run $PSVersionTable and be sure your PSVersion is 3.0
  2. Run Get-Module ShowUI -List | Format-Table Name, Version and be sure you only have one module listed, and that it is version 1.4
If your versions are right, can you try this and let me know where it goes wrong, exactly?
StackPanel -ControlName "Prompt" -Margin "8,0,8,8" {
    Label "Please Enter Your Full Name:"
    StackPanel -Orientation Horizontal {
        TextBox -Name FullName -Width 100
        Button "OK" -IsDefault -Width 50 -Margin "8,0,0,0" -On_Click {
            Write-Host "FullName:" $FullName.Text
            Write-Host "Prompt should be a ...StackPanel:" $Prompt
            $x = Set-UIValue $Prompt -Passthru
            Write-Host "X should be a ...StackPanel:" $X
            Close-Control $window # I like to explicitly close the $window instead of the control
        }
    }
} -On_Loaded { $FullName.Focus() } -Show 
May 19, 2013 at 2:03 PM

Once more, be aware I'm running from Windows Server 2012 Datacenter build 9200, NOT windos 8

(I have found many incompatibilities between the two all related to .NET: Win8 comes with .NET 4.0, 2012 with 4.5,

I know there should be no incompatibilities, but sadly it seems there are plentyfull)

1)

PS C:\> $PSVersionTable

Name Value

---- -----

PSVersion 3.0

WSManStackVersion 3.0

SerializationVersion 1.1.0.1

CLRVersion 4.0.30319.18033

BuildVersion 6.2.9200.16434

PSCompatibleVersions {1.0, 2.0, 3.0}

PSRemotingProtocolVersion 2.2

2)

PS C:\> Get-Module ShowUI -List | Format-Table Name, Version

Name Version

---- -------

ShowUI 1.4

Your example gives me what I posted:

1) The window shows up, but is NOT focused

2) Clicking inside textfield, I can enter text

3) hitting enter or clicking OK, nothing happens

4) Closing the window, no output gets set, as you explain, it's like cancelling, so that's understandable

5) What's not understandable, is that clicking OK doesn't exist the window with result

Please read my post again, this was one of two ways to program this example, the other one than this one does work,

(using $window.close()) but throws an error as decribed. None of the examples work, for example the one on homepage about eventlog gives me this:

1) Windows opens, I can chose a date

2) When I click Events, following eror shows up:

PS C:\> Get-EventLog @getEventInput

Get-EventLog : A parameter cannot be found that matches parameter name 'toggleButton'.

At line:1 char:14

+ Get-EventLog @getEventInput

+ ~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: (:) [Get-EventLog], ParameterBindingException

+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetEventLogCommand

The error is correct in that if I look at what's returned, it gives me:

PS C:\> $geteventinput

Name Value

---- -----

toggleButton False

LogName Application

After 18-05-2013 00:00:00

Ofcourse, the get-eventlog cannot deal with that object…

I'm convinced nothing is wrong with ShowUI, it just doesn't seem to work on server 2012

I've tried on at least 3 different 2012 servers, some having .NET 3.5 aswell as 4.5 installed (see Server Manager), and others only having 4.5 installed

Results are consistent and always like the above… The examples from the examples folder all don't work or give errors, similar to these examples

Also ran from a vanilla 2012 server, same results. Has ShowUI been tested on a 2012 server ?

Met vriendelijke groet / Kind regards,

Bart van de Beek

[email removed]

M: 0031 6 42626589

May 20, 2013 at 10:57 AM
I've verified on vanilla Windows 8, get the same results...
I noticed the following:
In the video from James about running showui side by side:
http://www.youtube.com/watch?v=gQTGi5kUGKk

I noticed James runs get-uicommand | measure-object
His results on .net 3.5 are 184 commands, 218 commands on .net 4.0

Running same command I consistently get
PS C:> get-uicommand | measure-object


Count : 122
Average :
Sum :
Maximum :
Minimum :
Property :

Whether I'm running on Windows Server 2012 or Windows 8, both vanilla...

once again, on Windows 8, the home-page example gives me same result again:

PS C:> $getEventInput = StackPanel -ControlName 'Get-EventLogsSinceDate' {
New-Label -VisualStyle 'MediumText' "Log Name"
New-ComboBox -IsEditable:$false -SelectedIndex 0 -Name LogName @("Application", "Security", "System", "Setup")
New-Label -VisualStyle 'MediumText' "Get Event Logs Since..."
Select-Date -Name After
New-Button "Get Events" -On_Click {
    Get-ParentControl |
        Set-UIValue -passThru |
        Close-Control
}
} -show

PS C:> Get-EventLog @getEventInput
Get-EventLog : A parameter cannot be found that matches parameter name 'toggleButton'.
At line:1 char:14
  • Get-EventLog @getEventInput
  • ~~~~~~~~~~~~~~
    • CategoryInfo : InvalidArgument: (:) [Get-EventLog], ParameterBindingException
    • FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetEventLogCommand
This leads me to believe the showui.1.4.zip offered here is broken/incomplete...
Could this be the case ? Please verify...
Thanks in advance...
Jun 24, 2013 at 11:16 AM
Hi,

When i'm running :
$getEventInput = StackPanel -ControlName 'Get-EventLogsSinceDate' {

    New-Label -VisualStyle 'MediumText' "Log Name"
    New-ComboBox -IsEditable:$false -SelectedIndex 0 -Name LogName @("Application", "Security", "System", "Setup")
    New-Label -VisualStyle 'MediumText' "Get Event Logs Since..."
    Select-Date -Name After
    New-Button "Get Events" -On_Click {
        Get-ParentControl |
            Set-UIValue -passThru |
            Close-Control
    }
} -show

Get-EventLog @getEventInput
I have the same Issue Here on Win2k12 and no issue on Win7 with this code
Get-EventLog : Impossible de trouver un paramètre correspondant au nom « toggleButton ».
Au caractère Ligne:14 : 14
+ Get-EventLog @getEventInput
+              ~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument : (:) [Get-EventLog], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetEventLogCommand
Coordinator
Jun 24, 2013 at 6:56 PM
@Wizard17 and @DaCthulHu -- please folks, new thread!

There's nothing wrong, per-se, except that the example needs to be changed because it's outputting an EXTRA record "toggleButton" -- I'm not actually sure why it's doing that, because if you run it with just the New-ComboBox or just the Select-Date it runs fine, but somehow putting those together on the same form causes problems.

See this thread please: https://showui.codeplex.com/discussions/439341