label 'Hello World' -Show
The content is usually the first parameter-FontSize makes it bigger.
New-Label 'Hello World' -FontFamily 'Consolas' -FontSize 24 -FontWeight Bold -AsJob
Get-UICommand
New-TextBox -text 'default' -show
New-UniformGrid -Width 200 -Height 200 { New-Rectangle 'Red' New-Rectangle 'Green' New-Rectangle 'Blue' New-Rectangle 'Yellow' } -show
New-Menu -ControlName SampleMenu { New-MenuItem "File" { New-MenuItem "E_xit" -on_click { $window.Close() } } } -show
$picture = Get-ChildItem "$env:PUBLIC\Pictures\Sample Pictures" | Get-Random New-Image -Source "$($picture.Fullname)" -Width 640 -Height 480 -show
$getCommandInput = UniformGrid -ControlName 'Get-InputForGetCommand' -Columns 2 { "Command Name" New-TextBox -Name Name "Verb" New-TextBox -Name Verb "Noun" New-TextBox -Name Noun "In Module" New-TextBox -Name Module " " # Some Empty Space New-Button "Get Command" -On_Click { Get-ParentControl | Set-UIValue -passThru | Close-Control } } -show Get-Command @getCommandInput
$getEventInput = StackPanel -ControlName 'Get-EventLogsSinceDate' { New-Label -VisualStyle 'MediumText' "Get Event Logs Since..." New-ComboBox -IsEditable:$false -SelectedIndex 0 -Name LogName @("Application", "Security", "System", "Setup") Select-Date -Name After New-Button "Get Events" -On_Click { Get-ParentControl | Set-UIValue -passThru | Close-Control } } -show Get-EventLog @getEventInput
New-Grid -ControlName 'SessionManager' -Rows ( 'Auto', # Automatically sized header row '1*', # The remaining space will be where the list of sessions is displayed 'Auto' # Buttons will go along the bottom ) { "Active Sessions" New-ListView -Row 1 -Name SessionList -View { New-GridView -Columns { New-GridViewColumn -Header 'Id' -DisplayMemberBinding 'Id' New-GridViewColumn 'Name' New-GridViewColumn 'ComputerName' New-GridViewColumn 'ConfigurationName' New-GridViewColumn 'State' } } New-UniformGrid -Row 2 -Rows 1 { New-Button "_Open" -Name OpenSession -On_Click { # It's very easy to do nested dialogs. Simply create a new control inside of # an event handler, and use -Show. $sessionParameters = New-UniformGrid -ControlName 'Get-RemoteSessionOption' -Columns 2 { 'ComputerName' New-TextBox -Name 'ComputerName' 'ConfigurationName' New-TextBox -Name 'ConfigurationName' 'Authentication' New-ComboBox -Name 'Authentication' -SelectedIndex 0 -ItemsSource { [Enum]::GetValues([Management.Automation.Runspaces.AuthenticationMechanism]) } New-Button "Connect" -On_Click { $parent | Update-UIValue -passThru | Close-Control } New-Button "Connect As..." -On_Click { $parent | Update-UIValue $parent.Tag.Credential = Get-Credential $parent | Close-Control } } -show if ($sessionParameters) { New-PSSession @sessionParameters $sessionList.ItemsSource = @(Get-PSSession) } } New-Button "_Close" -On_Click { $sessionList.SelectedItem | Remove-PSSession $sessionList.ItemsSource = @(Get-PSSession) } } } -On_Loaded { $sessionList.ItemsSource = @(Get-PSSession) } -show