Citrix GUI App Modify Servers

Get a list of Applications and add or remove servers

Reinventing the wheel

This is stuff you can already do in the console just making a simplified UI for this one task

######################################################################## # Code Generated By: SAPIEN Technologies, Inc., PrimalForms 2009 v1.1.11.0 # Generated On: 12/13/2010 5:14 PM # Generated By: Kevin Curran # Organization: Disorganized ########################################################################  #---------------------------------------------- #region Application Functions #----------------------------------------------  function OnApplicationLoad { #Note: This function runs before the form is created #Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path #Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList) #Important: Form controls cannot be accessed in this function #TODO: Add snapins and custom code to validate the application load Add-PSSnapin Citrix.XenApp.Commands return $true #return true for success or false for failure }  function OnApplicationExit { #Note: This function runs after the form is closed #TODO: Add custom code to clean up and unload snapins when the application exits $script:ExitCode = 0 #Set the exit code for the Packager }  #endregion  #---------------------------------------------- # Generated Form Function #---------------------------------------------- function GenerateForm {  #---------------------------------------------- #region Import Assemblies #---------------------------------------------- [void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") [void][reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") #endregion #---------------------------------------------- #region Generated Form Objects #---------------------------------------------- [System.Windows.Forms.Application]::EnableVisualStyles() $frmCitrixAppsGUI = New-Object System.Windows.Forms.Form $lblError = New-Object System.Windows.Forms.Label $btnRemove = New-Object System.Windows.Forms.Button $btnAdd = New-Object System.Windows.Forms.Button $listboxAppServers = New-Object System.Windows.Forms.ListBox $listboxAvailableServers = New-Object System.Windows.Forms.ListBox $lblAppServers = New-Object System.Windows.Forms.Label $lblAvailibleServers = New-Object System.Windows.Forms.Label $btnGetServers = New-Object System.Windows.Forms.Button $listboxApps = New-Object System.Windows.Forms.ListBox $btnGetApps = New-Object System.Windows.Forms.Button $tooltip = New-Object System.Windows.Forms.ToolTip $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState #endregion Generated Form Objects  #---------------------------------------------- # User Generated Script #----------------------------------------------  function GetAppServers { $XAServers= Get-XAServer $XAAppServers= Get-XAServer -BrowserName $App $XAAvailableServers = Compare-Object $XAServers $XAAppServers $listboxAvailableServers.items.Clear() $listboxAppServers.items.Clear() if ($XAAppServers -ne $null) { foreach ($Server in $XAAppServers) { $listboxAppServers.Items.Add($Server.Servername) } } if ($XAAvailableServers -ne $null) { foreach ($Server in $XAAvailableServers) { $listboxAvailableServers.Items.Add($Server.InputObject) } } } $FormEvent_Load={ #TODO: Initialize Form Controls here } $handler_btnGetApps_Click={ $lblError.Text = "" $XAApps = Get-XAApplication foreach ($App in $XAApps) { $listboxApps.Items.Add($App.BrowserName)  } }#end handler_btnGetApps_Click $handler_btnGetServers_Click={ $lblError.Text = "" $App=$($listboxApps.SelectedItem) GetAppServers }#end handler_btnGetServers_Click $ShowTooltip={ #display tooltip #http://jdhitsolutions.com/blog/2009/09/add-tooltip-help-to-your-primalforms-script/ switch ($this.name) { "btnAdd" {$tip="Add Selected Server"} "btnRemove" {$tip="Remove Selected Server"} default {$tip="No help found for $($this.name)"} } $tooltip.SetToolTip($this,$tip) }#end ShowTooltip $handler_btnAdd_Click={ #TODO: Place custom script here $lblError.Text = "" if ($listboxAvailableServers.SelectedItem -eq $null) { $lblError.Text = "Please Select a server from the list of available servers" } Else { $lblError.Text = "Adding Server $($listboxAvailableServers.SelectedItem)" Add-XAApplicationServer -BrowserName $App -ServerNames $($listboxAvailableServers.SelectedItem) GetAppServers } }#end handler_btnAdd_Click $handler_btnRemove_Click={ #TODO: Place custom script here $lblError.Text = "" if ($listboxAppServers.SelectedItem -eq $null) { $lblError.Text = "Please Select a server from the list of App servers" } Else { $lblError.Text = "Removing Server $($listboxAppServers.SelectedItem)" Remove-XAApplicationServer -BrowserName $App -ServerNames $($listboxAppServers.SelectedItem) GetAppServers } }#end handler_btnRemove_Click #---------------------------------------------- # Generated Events #---------------------------------------------- $Form_StateCorrection_Load= { #Correct the initial state of the form to prevent the .Net maximized form issue $frmCitrixAppsGUI.WindowState = $InitialFormWindowState } #---------------------------------------------- #region Generated Form Code #---------------------------------------------- # # frmCitrixAppsGUI # $frmCitrixAppsGUI.Controls.Add($lblError) $frmCitrixAppsGUI.Controls.Add($btnRemove) $frmCitrixAppsGUI.Controls.Add($btnAdd) $frmCitrixAppsGUI.Controls.Add($listboxAppServers) $frmCitrixAppsGUI.Controls.Add($listboxAvailableServers) $frmCitrixAppsGUI.Controls.Add($lblAppServers) $frmCitrixAppsGUI.Controls.Add($lblAvailibleServers) $frmCitrixAppsGUI.Controls.Add($btnGetServers) $frmCitrixAppsGUI.Controls.Add($listboxApps) $frmCitrixAppsGUI.Controls.Add($btnGetApps) $frmCitrixAppsGUI.ClientSize = New-Object System.Drawing.Size(336,444) $frmCitrixAppsGUI.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $frmCitrixAppsGUI.Name = "frmCitrixAppsGUI" $frmCitrixAppsGUI.Text = "Citrix Apps GUI" $frmCitrixAppsGUI.add_Load($FormEvent_Load) # # lblError # $lblError.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $lblError.Location = New-Object System.Drawing.Point(13,409) $lblError.Name = "lblError" $lblError.Size = New-Object System.Drawing.Size(311,23) $lblError.TabIndex = 9 # # btnRemove # $btnRemove.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $btnRemove.Location = New-Object System.Drawing.Point(152,262) $btnRemove.Name = "btnRemove" $btnRemove.Size = New-Object System.Drawing.Size(30,23) $btnRemove.TabIndex = 8 $btnRemove.Text = "<" $btnRemove.UseVisualStyleBackColor = $True $btnRemove.add_Click($handler_btnRemove_Click) $btnRemove.add_MouseHover($ShowTooltip) # # btnAdd # $btnAdd.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $btnAdd.Location = New-Object System.Drawing.Point(152,232) $btnAdd.Name = "btnAdd" $btnAdd.Size = New-Object System.Drawing.Size(30,23) $btnAdd.TabIndex = 7 $btnAdd.Text = ">" $btnAdd.UseVisualStyleBackColor = $True $btnAdd.add_Click($handler_btnAdd_Click) $btnAdd.add_MouseHover($ShowTooltip) # # listboxAppServers # $listboxAppServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $listboxAppServers.FormattingEnabled = $True $listboxAppServers.Location = New-Object System.Drawing.Point(204,212) $listboxAppServers.Name = "listboxAppServers" $listboxAppServers.Size = New-Object System.Drawing.Size(120,95) $listboxAppServers.TabIndex = 6 # # listboxAvailableServers # $listboxAvailableServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $listboxAvailableServers.FormattingEnabled = $True $listboxAvailableServers.Location = New-Object System.Drawing.Point(13,212) $listboxAvailableServers.Name = "listboxAvailableServers" $listboxAvailableServers.Size = New-Object System.Drawing.Size(120,95) $listboxAvailableServers.TabIndex = 5 # # lblAppServers # $lblAppServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $lblAppServers.Location = New-Object System.Drawing.Point(204,190) $lblAppServers.Name = "lblAppServers" $lblAppServers.Size = New-Object System.Drawing.Size(120,18) $lblAppServers.TabIndex = 4 $lblAppServers.Text = "App Servers" # # lblAvailibleServers # $lblAvailibleServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $lblAvailibleServers.Location = New-Object System.Drawing.Point(12,190) $lblAvailibleServers.Name = "lblAvailibleServers" $lblAvailibleServers.Size = New-Object System.Drawing.Size(120,18) $lblAvailibleServers.TabIndex = 3 $lblAvailibleServers.Text = "Availible Servers" # # btnGetServers # $btnGetServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $btnGetServers.Location = New-Object System.Drawing.Point(13,144) $btnGetServers.Name = "btnGetServers" $btnGetServers.Size = New-Object System.Drawing.Size(121,23) $btnGetServers.TabIndex = 2 $btnGetServers.Text = "Get Servers" $btnGetServers.UseVisualStyleBackColor = $True $btnGetServers.add_Click($handler_btnGetServers_Click) # # listboxApps # $listboxApps.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $listboxApps.FormattingEnabled = $True $listboxApps.Location = New-Object System.Drawing.Point(13,43) $listboxApps.Name = "listboxApps" $listboxApps.Size = New-Object System.Drawing.Size(120,95) $listboxApps.TabIndex = 1 # # btnGetApps # $btnGetApps.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $btnGetApps.Location = New-Object System.Drawing.Point(13,13) $btnGetApps.Name = "btnGetApps" $btnGetApps.Size = New-Object System.Drawing.Size(120,23) $btnGetApps.TabIndex = 0 $btnGetApps.Text = "Get Applications" $btnGetApps.UseVisualStyleBackColor = $True $btnGetApps.add_Click($handler_btnGetApps_Click) # # tooltip # $tooltip.IsBalloon = $True #endregion Generated Form Code  #----------------------------------------------  #Save the initial state of the form $InitialFormWindowState = $frmCitrixAppsGUI.WindowState #Init the OnLoad event to correct the initial state of the form $frmCitrixAppsGUI.add_Load($Form_StateCorrection_Load) #Show the Form return $frmCitrixAppsGUI.ShowDialog()  } #End Function  #Call OnApplicationLoad to initialize if(OnApplicationLoad -eq $true) { #Create the form GenerateForm | Out-Null #Perform cleanup OnApplicationExit }

                                                                                                                      

Same thing but added ugly stuff to run the add and remove servers as a different account.

######################################################################## # Code Generated By: SAPIEN Technologies, Inc., PrimalForms 2009 v1.1.11.0 # Generated On: 12/16/2010 12:02 PM # Generated By: Kevin Curran # Organization: Disorganized ########################################################################  #---------------------------------------------- #region Application Functions #----------------------------------------------  function OnApplicationLoad { #Note: This function runs before the form is created #Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path #Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList) #Important: Form controls cannot be accessed in this function #TODO: Add snapins and custom code to validate the application load IF (Get-PSSnapin | where {$_.name -eq "Citrix.XenApp.Commands"})  {write-host "Citrix XenApp Commands snapin already loaded"} Else {add-PSSnapin  Citrix.XenApp.Commands} return $true #return true for success or false for failure }  function OnApplicationExit { #Note: This function runs after the form is closed #TODO: Add custom code to clean up and unload snapins when the application exits $script:ExitCode = 0 #Set the exit code for the Packager }  #endregion  #---------------------------------------------- # Generated Form Function #---------------------------------------------- function GenerateForm {  #---------------------------------------------- #region Import Assemblies #---------------------------------------------- [void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") [void][reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") [void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") #endregion #---------------------------------------------- #region Generated Form Objects #---------------------------------------------- [System.Windows.Forms.Application]::EnableVisualStyles() $frmCitrixAppsGUI = New-Object System.Windows.Forms.Form $lblError = New-Object System.Windows.Forms.Label $btnRemove = New-Object System.Windows.Forms.Button $btnAdd = New-Object System.Windows.Forms.Button $listboxAppServers = New-Object System.Windows.Forms.ListBox $listboxAvailableServers = New-Object System.Windows.Forms.ListBox $lblAppServers = New-Object System.Windows.Forms.Label $lblAvailibleServers = New-Object System.Windows.Forms.Label $btnGetServers = New-Object System.Windows.Forms.Button $listboxApps = New-Object System.Windows.Forms.ListBox $btnGetApps = New-Object System.Windows.Forms.Button $tooltip = New-Object System.Windows.Forms.ToolTip $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState #endregion Generated Form Objects  #---------------------------------------------- # User Generated Script #----------------------------------------------  $FormEvent_Load={ #TODO: Initialize Form Controls here $PSExec="c:\scripts\PsTools\PsExec.exe" $AdminAccount="Blah\CitrixAdmin" $AdminPassword="randompassword" #Define the Current Directory this can be different if you build an exe vs run the script if ($hostinvocation) {$ScriptDirectory = Split-Path $hostinvocation.MyCommand.path} Else { if($myInvocation.ScriptName)      {$ScriptDirectory= Split-Path $myInvocation.ScriptName }  else {$ScriptDirectory= Split-Path $myInvocation.MyCommand.Definition } } $LogDir = "$ScriptDirectory\Logs\" } function GetAppServers { $lblError.Text = "" $XAServers= Get-XAServer #http://forums.citrix.com/thread.jspa?threadID=278889&tstart=0 #Current version of this command does not work with a Citrix View Only Administrator #$XAAppServers= Get-XAServer -BrowserName $App $XAAppServers= Get-XAApplicationReport $App | Select -expand ServerNames | % { Get-XAServer $_ } $XAAvailableServers = Compare-Object $XAServers $XAAppServers $listboxAvailableServers.items.Clear() $listboxAppServers.items.Clear() if ($XAAppServers -ne $null) { foreach ($Server in $XAAppServers) { $listboxAppServers.Items.Add($Server.Servername) } } if ($XAAvailableServers -ne $null) { foreach ($Server in $XAAvailableServers) { $listboxAvailableServers.Items.Add($Server.InputObject) } } } function WriteLog( [string] $Message=$(throw '$message is required')) { #Example WriteLog("OMG Blah blah blah") $DateStamp = Get-Date -format yyyyMdd $Username=$env:USERNAME $logfile= $LogDir + $DateStamp + "_CitrixAppsGUI_Log.txt" "$(Get-date) $Username $Message "| Out-File -Append -FilePath $logfile } $handler_btnGetApps_Click={ $lblError.Text = "" $XAApps = Get-XAApplication foreach ($App in $XAApps) { $listboxApps.Items.Add($App.BrowserName)  } }#end handler_btnGetApps_Click $handler_btnGetServers_Click={ $lblError.Text = "" $App=$($listboxApps.SelectedItem) GetAppServers }#end handler_btnGetServers_Click $ShowTooltip={ #display tooltip #http://jdhitsolutions.com/blog/2009/09/add-tooltip-help-to-your-primalforms-script/ switch ($this.name) { "btnAdd" {$tip="Add Selected Server"} "btnRemove" {$tip="Remove Selected Server"} default {$tip="No help found for $($this.name)"} } $tooltip.SetToolTip($this,$tip) }#end ShowTooltip $handler_btnAdd_Click={ #TODO: Place custom script here $lblError.Text = "" if ($listboxAvailableServers.SelectedItem -eq $null) { $lblError.Text = "Please Select a server from the list of available servers" } Else { $lblError.Text = "Adding Server $($listboxAvailableServers.SelectedItem)" WriteLog("Adding Server $($listboxAvailableServers.SelectedItem) to Application $App") #Add-XAApplicationServer -BrowserName $App -ServerNames $($listboxAvailableServers.SelectedItem) #run command as a user with elevated rights & $PSExec -u $AdminAccount -p $AdminPassword PowerShell.exe -ExecutionPolicy unrestricted -noninteractive -nologo -WindowStyle hidden -Command "Add-PSSnapin Citrix.XenApp.Commands; Add-XAApplicationServer -BrowserName $App -ServerNames $($listboxAvailableServers.SelectedItem)" GetAppServers } }#end handler_btnAdd_Click $handler_btnRemove_Click={ #TODO: Place custom script here $lblError.Text = "" if ($listboxAppServers.SelectedItem -eq $null) { $lblError.Text = "Please Select a server from the list of App servers" } Else { $lblError.Text = "Removing Server $($listboxAppServers.SelectedItem)" WriteLog("Removing Server $($listboxAppServers.SelectedItem) from Application $App") #Remove-XAApplicationServer -BrowserName $App -ServerNames $($listboxAppServers.SelectedItem) #run command as a user with elevated rights & $PSExec -u $AdminAccount -p $AdminPassword PowerShell.exe -ExecutionPolicy unrestricted -noninteractive -nologo -WindowStyle hidden -Command "Add-PSSnapin Citrix.XenApp.Commands; Remove-XAApplicationServer -BrowserName $App -ServerNames $($listboxAppServers.SelectedItem)" GetAppServers } }#end handler_btnRemove_Click #---------------------------------------------- # Generated Events #---------------------------------------------- $Form_StateCorrection_Load= { #Correct the initial state of the form to prevent the .Net maximized form issue $frmCitrixAppsGUI.WindowState = $InitialFormWindowState } #---------------------------------------------- #region Generated Form Code #---------------------------------------------- # # frmCitrixAppsGUI # $frmCitrixAppsGUI.Controls.Add($lblError) $frmCitrixAppsGUI.Controls.Add($btnRemove) $frmCitrixAppsGUI.Controls.Add($btnAdd) $frmCitrixAppsGUI.Controls.Add($listboxAppServers) $frmCitrixAppsGUI.Controls.Add($listboxAvailableServers) $frmCitrixAppsGUI.Controls.Add($lblAppServers) $frmCitrixAppsGUI.Controls.Add($lblAvailibleServers) $frmCitrixAppsGUI.Controls.Add($btnGetServers) $frmCitrixAppsGUI.Controls.Add($listboxApps) $frmCitrixAppsGUI.Controls.Add($btnGetApps) $frmCitrixAppsGUI.ClientSize = New-Object System.Drawing.Size(336,444) $frmCitrixAppsGUI.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $frmCitrixAppsGUI.Name = "frmCitrixAppsGUI" $frmCitrixAppsGUI.Text = "Citrix Apps GUI" $frmCitrixAppsGUI.add_Load($FormEvent_Load) # # lblError # $lblError.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $lblError.Location = New-Object System.Drawing.Point(13,409) $lblError.Name = "lblError" $lblError.Size = New-Object System.Drawing.Size(311,23) $lblError.TabIndex = 9 # # btnRemove # $btnRemove.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $btnRemove.Location = New-Object System.Drawing.Point(152,262) $btnRemove.Name = "btnRemove" $btnRemove.Size = New-Object System.Drawing.Size(30,23) $btnRemove.TabIndex = 8 $btnRemove.Text = "<" $btnRemove.UseVisualStyleBackColor = $True $btnRemove.add_Click($handler_btnRemove_Click) $btnRemove.add_MouseHover($ShowTooltip) # # btnAdd # $btnAdd.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $btnAdd.Location = New-Object System.Drawing.Point(152,232) $btnAdd.Name = "btnAdd" $btnAdd.Size = New-Object System.Drawing.Size(30,23) $btnAdd.TabIndex = 7 $btnAdd.Text = ">" $btnAdd.UseVisualStyleBackColor = $True $btnAdd.add_Click($handler_btnAdd_Click) $btnAdd.add_MouseHover($ShowTooltip) # # listboxAppServers # $listboxAppServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $listboxAppServers.FormattingEnabled = $True $listboxAppServers.Location = New-Object System.Drawing.Point(204,212) $listboxAppServers.Name = "listboxAppServers" $listboxAppServers.Size = New-Object System.Drawing.Size(120,160) $listboxAppServers.TabIndex = 6 # # listboxAvailableServers # $listboxAvailableServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $listboxAvailableServers.FormattingEnabled = $True $listboxAvailableServers.Location = New-Object System.Drawing.Point(13,212) $listboxAvailableServers.Name = "listboxAvailableServers" $listboxAvailableServers.Size = New-Object System.Drawing.Size(120,160) $listboxAvailableServers.TabIndex = 5 # # lblAppServers # $lblAppServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $lblAppServers.Location = New-Object System.Drawing.Point(204,190) $lblAppServers.Name = "lblAppServers" $lblAppServers.Size = New-Object System.Drawing.Size(120,18) $lblAppServers.TabIndex = 4 $lblAppServers.Text = "App Servers" # # lblAvailibleServers # $lblAvailibleServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $lblAvailibleServers.Location = New-Object System.Drawing.Point(12,190) $lblAvailibleServers.Name = "lblAvailibleServers" $lblAvailibleServers.Size = New-Object System.Drawing.Size(120,18) $lblAvailibleServers.TabIndex = 3 $lblAvailibleServers.Text = "Availible Servers" # # btnGetServers # $btnGetServers.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $btnGetServers.Location = New-Object System.Drawing.Point(13,144) $btnGetServers.Name = "btnGetServers" $btnGetServers.Size = New-Object System.Drawing.Size(121,23) $btnGetServers.TabIndex = 2 $btnGetServers.Text = "Get Servers" $btnGetServers.UseVisualStyleBackColor = $True $btnGetServers.add_Click($handler_btnGetServers_Click) # # listboxApps # $listboxApps.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $listboxApps.FormattingEnabled = $True $listboxApps.Location = New-Object System.Drawing.Point(13,43) $listboxApps.Name = "listboxApps" $listboxApps.Size = New-Object System.Drawing.Size(120,95) $listboxApps.TabIndex = 1 # # btnGetApps # $btnGetApps.DataBindings.DefaultDataSourceUpdateMode = [System.Windows.Forms.DataSourceUpdateMode]::OnValidation  $btnGetApps.Location = New-Object System.Drawing.Point(13,13) $btnGetApps.Name = "btnGetApps" $btnGetApps.Size = New-Object System.Drawing.Size(120,23) $btnGetApps.TabIndex = 0 $btnGetApps.Text = "Get Applications" $btnGetApps.UseVisualStyleBackColor = $True $btnGetApps.add_Click($handler_btnGetApps_Click) # # tooltip # $tooltip.IsBalloon = $True #endregion Generated Form Code  #----------------------------------------------  #Save the initial state of the form $InitialFormWindowState = $frmCitrixAppsGUI.WindowState #Init the OnLoad event to correct the initial state of the form $frmCitrixAppsGUI.add_Load($Form_StateCorrection_Load) #Show the Form return $frmCitrixAppsGUI.ShowDialog()  } #End Function  #Call OnApplicationLoad to initialize if(OnApplicationLoad -eq $true) { #Create the form GenerateForm | Out-Null #Perform cleanup OnApplicationExit }