Skip to content

Missing Messages And Comments With Version 0.5.0 Using New-Object #21

@IanBAdams

Description

@IanBAdams

I've just been testing my scripts against version 0.5.0. All was fine until I tested the one script I have which uses New-Object rather than Show-AnyBox followed by parameters. This script works fine with version 0.4.0 but with version 0.5.0 the Messages and Comments are missing.

I've enclosed a simplified version of the AnyBox code below:
Import-Module AnyBox
$AnyBox = New-Object AnyBox.AnyBox
$DevicesList = @('PC-ELAINE','PC-IAN','PC-RICHARD','PC-SAMANTHA')

$AnyBox.Prompts = @( New-AnyBoxPrompt -InputType Text -Message "What's the name of the target computer?" -ValidateSet $DevicesList -ShowSetAs Radio -ValidateScript { $_ -Ne '' } )

$AnyBox.Buttons = 'Continue','Cancel'
$AnyBox.CancelButton = 'Cancel'
$AnyBox.DefaultButton = 'Continue'
$AnyBox.Comment = "","Comment line.",""
$AnyBox.Message = "Message line 1.","Message line 2."
$AnyBoxResult = $AnyBox | Show-AnyBox

With version 0.4.0 the following window is displayed:
image

However, with exactly the same code in version 0.5.0 I get:
image

If I change the code as follows:
$DevicesList = @('PC-ELAINE','PC-IAN','PC-RICHARD','PC-SAMANTHA')

$Prompt = @( New-AnyBoxPrompt -InputType Text -Message "What's the name of the target computer?" -ValidateSet $DevicesList -ShowSetAs Radio -ValidateScript { $_ -Ne '' } )

$AnyBoxResult = Show-AnyBox -Buttons 'Continue','Cancel' -CancelButton 'Cancel' -DefaultButton 'Continue' -Comments "","Comment line.","" -Messages "Message line 1.","Message line 2." -Prompts $Prompt

I get the following window with version 0.5.0 (i.e. the same as the New-Object method with version 0.4.0):
image

Obviously this isn't a big deal since I can rewrite the code. However, there are times where the New-Object method is preferable - i.e. if you want different messages or comments depending on some variable.

Let me know if anything is unclear or you need more information.

Many thanks
Ian

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions