add script entry point

This commit is contained in:
onyx-and-iris 2023-11-29 22:54:52 +00:00
parent 4966bee0b8
commit 61f7afb9f7

View File

@ -75,20 +75,27 @@ Function Get-ConnFromPSD1 {
return Import-PowerShellDataFile -Path $configpath return Import-PowerShellDataFile -Path $configpath
} }
try { Function Main {
$conn = Get-ConnFromPSD1 try {
$rcon = Connect-Rcon -hostname $conn.host -port $conn.port -passwd $conn.passwd $conn = Get-ConnFromPSD1
Write-Host $rcon.base.ToString() -ForegroundColor Green $rcon = Connect-Rcon -hostname $conn.host -port $conn.port -passwd $conn.passwd
Write-Host $rcon.base.ToString() -ForegroundColor Green
$form = InitForm $form = InitForm
AddOkButton -form $form -rcon $rcon AddOkButton -form $form -rcon $rcon
AddCloseButton($form) AddCloseButton($form)
AddLabel($form) AddLabel($form)
AddTextBox -form $form -rcon $rcon AddTextBox -form $form -rcon $rcon
FinalizeForm($form) FinalizeForm($form)
[void] $form.ShowDialog() [void] $form.ShowDialog()
}
finally {
Disconnect-Rcon -rcon $rcon
}
} }
finally {
Disconnect-Rcon -rcon $rcon
if ($MyInvocation.InvocationName -ne '.') {
Main
} }