GUI Script to pull all services on remote server, won't show Log on as account

Hello, I would really appreciate any help on my script. It creates a GUI that will pull all services from a remote server and when selecting a service, it shows the current status. I am trying to make it show the log on as account for the selected service, but it does not show anything. If I run the same code by itself, it does work correctly. TIA.

#region # Function Show-FunctionSelectorGUI - Will create initial GUI to enter server name and select option
function Show-FunctionSelectorGUI {
# Create a new GUI window
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object System.Windows.Forms.Form
$Form.Text = “Server Management”
$Form.Width = 875
$Form.Height = 625
$Form.StartPosition = “CenterScreen”
$Form.BackColor = [System.Drawing.Color]::DodgerBlue
$Form.ForeColor = [System.Drawing.Color]::White

# Create a label and text box for server input
$ServerLabel = New-Object System.Windows.Forms.Label
$ServerLabel.Location = New-Object System.Drawing.Point(10, 20)
$ServerLabel.Size = New-Object System.Drawing.Size(100, 20)
$ServerLabel.Text = "Enter server name:"
$Form.Controls.Add($ServerLabel)

# Add label for service status
$StatusLabel = New-Object System.Windows.Forms.Label
$StatusLabel.Location = New-Object System.Drawing.Point(10, 40)
$StatusLabel.Size = New-Object System.Drawing.Size(200, 20)
$Form.Controls.Add($StatusLabel)

# Add label for service logon account
$AccountLabel = New-Object System.Windows.Forms.Label
$AccountLabel.Location = New-Object System.Drawing.Point(10, 60)
$AccountLabel.Size = New-Object System.Drawing.Size(200, 20)
$Form.Controls.Add($AccountLabel)

$ServerTextBox = New-Object System.Windows.Forms.TextBox
$ServerTextBox.Location = New-Object System.Drawing.Point(170, 20)
$ServerTextBox.Size = New-Object System.Drawing.Size(200, 20)
$Form.Controls.Add($ServerTextBox)

# Create a drop down box to select different options
$FunctionSelector = New-Object System.Windows.Forms.ComboBox
$FunctionSelector.Location = New-Object System.Drawing.Point(380, 20)
$FunctionSelector.Size = New-Object System.Drawing.Size(200, 20)
$FunctionSelector.Items.Add("View Services")
$Form.Controls.Add($FunctionSelector)

# Create buttons to start or stop the selected service
$StartButton = New-Object System.Windows.Forms.Button
$StartButton.Location = New-Object System.Drawing.Point(750, 95)
$StartButton.Size = New-Object System.Drawing.Size(100, 30)
$StartButton.Text = "Start"
$StartButton.Visible = $false
$StartButton.BackColor = [System.Drawing.Color]::Green
$StartButton.ForeColor = [System.Drawing.Color]::White
$Form.Controls.Add($StartButton)

$StopButton = New-Object System.Windows.Forms.Button
$StopButton.Location = New-Object System.Drawing.Point(750, 135)
$StopButton.Size = New-Object System.Drawing.Size(100, 30)
$StopButton.Text = "Stop"
$StopButton.Visible = $false
$StopButton.BackColor = [System.Drawing.Color]::Red
$StopButton.ForeColor = [System.Drawing.Color]::White
$Form.Controls.Add($StopButton)

# Create a list box to display results
$ResultListBox = New-Object System.Windows.Forms.ListBox
$ResultListBox.Location = New-Object System.Drawing.Point(10, 90)
$ResultListBox.Size = New-Object System.Drawing.Size(720, 500)
$ResultListBox.BackColor = [System.Drawing.Color]::LightGray 
$ResultListBox.ForeColor = [System.Drawing.Color]::Black
$Form.Controls.Add($ResultListBox)
# Add handler for showing service status

$ResultListBox.add_SelectedIndexChanged(
{
    if ($FunctionSelector.SelectedItem -eq "View services")
    {
        $ServiceName = $ResultListBox.SelectedItem
        $Server = $ServerTextBox.Text.Trim()

        if ($ServiceName -ne $null -and $Server -ne $null) 
        {
            # Get the selected service and update the status label
            $Service = Get-Service -ComputerName $Server -Name $ServiceName
            $LogonAccount = (Get-WmiObject -Class Win32_Service -Filter "Name='$ServiceName'" -ComputerName $Server).StartName
            $StatusLabel.Text = "Service status: " + $Service.Status
            $AccountLabel.Text = "Logon account: $($LogonAccount)"
        }
    }
})




# Add a button to clear current selections
$ClearSelectionButton = New-Object System.Windows.Forms.Button
$ClearSelectionButton.Location = New-Object System.Drawing.Point(750, 55)
$ClearSelectionButton.Size = New-Object System.Drawing.Size(100, 30)
$ClearSelectionButton.Text = "Clear Selection"
$ClearSelectionButton.BackColor = [System.Drawing.Color]::LightGray 
$ClearSelectionButton.ForeColor = [System.Drawing.Color]::Black
$ClearSelectionButton.Add_Click({
    $ServerTextBox.Text = ""
    $StartButton.Visible = $false
    $StopButton.Visible = $false
    $StatusLabel.Text = ""
    $AccountLabel.Text = ""
    $FunctionSelector.SelectedIndex = -1
    $ResultListBox.Items.Clear()
})
$Form.Controls.Add($ClearSelectionButton)

#endregion
#################################################################

#region # Add an event handler for the Start and Stop buttons
$StartButton.Add_Click({
$Server = $ServerTextBox.Text
$service = $ResultListBox.SelectedItem
if ($service) {
try {
Get-Service -Name $service -ComputerName $Server | Start-Service
$StatusLabel.Text = "Service status: " + (Get-Service -Name $service -ComputerName $Server).Status.ToString()
} catch {
$ResultListBox.Items.Clear()
$ResultListBox.Items.Add(“Unable to start service $service on server $Server.”)
}
} else {
$ResultListBox.Items.Clear()
$ResultListBox.Items.Add(“Please select a service to start.”)
}
})

$StopButton.Add_Click({
$Server = $ServerTextBox.Text
$service = $ResultListBox.SelectedItem
if ($service) {
    try {
        Get-Service -Name $service -ComputerName $Server | Stop-Service
        $StatusLabel.Text = "Service status: " + (Get-Service -Name $service -ComputerName $Server).Status.ToString()
    } catch {
        $ResultListBox.Items.Clear()
        $ResultListBox.Items.Add("Unable to stop service $service on server $Server.")
    }
} else {
    $ResultListBox.Items.Clear()
    $ResultListBox.Items.Add("Please select a service to stop.")
}
})

#endregion

#################################################################

#region # Add a button to retrieve information based on selected option
$GetInformationButton = New-Object System.Windows.Forms.Button
$GetInformationButton.Location = New-Object System.Drawing.Point(600, 15)
$GetInformationButton.Size = New-Object System.Drawing.Size(120, 30)
$GetInformationButton.Text = “Get Information”
$GetInformationButton.BackColor = [System.Drawing.Color]::LightGray
$GetInformationButton.ForeColor = [System.Drawing.Color]::Black
$GetInformationButton.Add_Click({
$Server = $ServerTextBox.Text.Trim()
$SelectedOption = $FunctionSelector.SelectedItem.ToString()
$StatusLabel.Text = “”
$AccountLabel.Text = “”
$ResultListBox.Items.Clear()

    if ($SelectedOption -eq "View Services") {
        $StartButton.Visible = $true
        $StopButton.Visible = $true
    } else {
        $StartButton.Visible = $false
        $StopButton.Visible = $false
    }

    if ($Server) {
        try {
            switch ($SelectedOption) {
                
                "View Services" {
                    $ResultListBox.Items.Add("Fetching Services...")
                    Get-Services -ComputerName $Server
                }
            }
        } catch {
            $ResultListBox.Items.Clear()
            Write-Host $_
            $ResultListBox.Items.Add("Unable to retrieve information on server $Server.")
        }
    } else {
        $ResultListBox.Items.Clear()
        $ResultListBox.Items.Add("Please enter a server name.")
    }
})
    $Form.Controls.Add($GetInformationButton)

    # Add an event handler for the Enter key to
    $SearchBox = New-Object System.Windows.Forms.TextBox
    $SearchBox.add_KeyDown({
    if ($_.KeyCode -eq "Enter") {
        $GetInformationButton.PerformClick()
    }
    })

# Add exit button
$ExitButton = New-Object System.Windows.Forms.Button
$ExitButton.Location = New-Object System.Drawing.Point(750, 15)
$ExitButton.Size = New-Object System.Drawing.Size(100, 30)
$ExitButton.BackColor = [System.Drawing.Color]::LightGray 
$ExitButton.ForeColor = [System.Drawing.Color]::Black
$ExitButton.Text = "Exit"
$ExitButton.Add_Click({
    $Form.Close()
})
$Form.Controls.Add($ExitButton)

# Display the form
$Form.ShowDialog() | Out-Null

}

#endregion
#################################################################

#region # Function Get-Services - Will retrieve all services on selected service and will display the current status
function Get-Services
{
param (
[string]$ComputerName
)
try
{
# Retrieve the list of services on the server
$Services = Get-Service -ComputerName $Server | Sort-Object -Property @{Expression = “DisplayName”; Descending = $false}
$ResultListBox.Items.Clear()
$Services | ForEach-Object{
$ResultListBox.Items.Add($.DisplayName)
}
} catch
{
$ResultListBox.Items.Clear()
Write-Host $

$ResultListBox.Items.Add(“Unable to retrieve running services on server $ComputerName.”)
}

}
#endregion
#################################################################

Show-FunctionSelectorGUI

Have you looked at just using Out-Gridview for this?

Utilizing PowerShell Out-GridView as a GUI Alternative – SPIDERZEBRA