Files
FS_Admin_Panel/new_GUI.ps1
Florian Späth afb2f418fc init
2025-01-31 01:49:31 +01:00

841 lines
42 KiB
PowerShell

$Script:Version = "FS Admin Panel v0.8"
#Ersteller: Florian Späth
#Diese Software soll helfen die verschiedensten Anwendungen und Scripte der FG HDS zu administrieren.
Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.Windows.Forms
[System.Reflection.Assembly]::LoadWithPartialName('System.Drawing') | Out-Null
### Variablen Definition ###
# array = Settings ,
$script:array=@($false,$true)
function getValues($formTitle, $textTitle){
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = $formTitle
$objForm.Size = New-Object System.Drawing.Size(300,200)
$objForm.StartPosition = "CenterScreen"
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$x=$objTextBox.Text;$objForm.Close()}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}})
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.Add_Click({$Script:userInput=$objTextBox.Text;$objForm.Close()})
$objForm.Controls.Add($OKButton)
$CANCELButton = New-Object System.Windows.Forms.Button
$CANCELButton.Location = New-Object System.Drawing.Size(150,120)
$CANCELButton.Size = New-Object System.Drawing.Size(75,23)
$CANCELButton.Text = "CANCEL"
$CANCELButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CANCELButton)
$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,30)
$objLabel.Text = $textTitle
$objForm.Controls.Add($objLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,50)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)
$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
return $userInput
}
### $schema = getValues "Database Schema" "Enter database schema"
#### Lädt Scripte ####
function Load_main {
[XML]$Form = @"
<?xaml encoding="utf-8"?>
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfApp1"
Title="MainWindow" Height="960" Width="1442" Background="#1a1a1a" ResizeMode="NoResize" WindowStyle="None">
<Grid>
<Border BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0.5" Height="93" VerticalAlignment="Top" Margin="10,821,0,0"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Width="108" Height="950" FontSize="12" BorderBrush="Gray" Background="#0a0a0a" Foreground="White" Margin="1,10,0,0"/>
<Label HorizontalAlignment="Center" VerticalAlignment="Top" Width="1442" Height="76" FontSize="12" BorderBrush="Gray" Background="#0a0a0a" Foreground="White"/>
<Border BorderBrush="Gray" BorderThickness="0.5,0.5,0.5,0.5" Height="914" VerticalAlignment="Top" Margin="1372,0,0,0"/>
<Button TabIndex="1" Name="menu1" BorderThickness="0" HorizontalAlignment="Left" Margin="20,109,0,0" VerticalAlignment="Top" Width="70" Height="70" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
<Image x:Name="img1" Source="{Binding}"/>
</Button>
<Button TabIndex="1" x:Name="menu2" BorderThickness="0" HorizontalAlignment="Left" Margin="20,199,0,0" VerticalAlignment="Top" Width="70" Height="70" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
<Image x:Name="img2" Source="{Binding}"/>
</Button>
<Button TabIndex="1" x:Name="menu3" BorderThickness="0" HorizontalAlignment="Left" Margin="20,289,0,0" VerticalAlignment="Top" Width="70" Height="70" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
<Image x:Name="img3" Source="{Binding}"/>
</Button>
<Button TabIndex="1" x:Name="menu4" BorderThickness="0" HorizontalAlignment="Left" Margin="20,382,0,0" VerticalAlignment="Top" Width="70" Height="70" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
<Image x:Name="img4" Source="{Binding}"/>
</Button>
<Button TabIndex="1" x:Name="menu5" BorderThickness="0" HorizontalAlignment="Left" Margin="20,475,0,0" VerticalAlignment="Top" Width="70" Height="70" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
<Image x:Name="img5" Source="{Binding}"/>
</Button>
<Button TabIndex="1" x:Name="menu6" BorderThickness="0" HorizontalAlignment="Left" Margin="20,567,0,0" VerticalAlignment="Top" Width="70" Height="70" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
<Image x:Name="img6" Source="{Binding}"/>
</Button>
<Button Name="btninfo" HorizontalAlignment="Left" Margin="31,844,0,0" VerticalAlignment="Top" Width="48" Height="48" BorderThickness="0" Background="#292929" FontSize="40" Foreground="White">
<Button.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="2"/>
</Style>
</Button.Resources>
<Image x:Name="imginfo" Source="{Binding}"/>
</Button>
<Button TabIndex="4" x:Name="btnsettings" BorderThickness="0" HorizontalAlignment="Left" Margin="1291,833,0,0" VerticalAlignment="Top" Width="67" Height="70" FontSize="40" Background="#292929" Foreground="White" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="2"/>
</Style>
</Button.Resources>
<Image x:Name="imgsettings" Source="{Binding}"/>
</Button>
<TextBox Name="log" Text="" BorderThickness="0" HorizontalAlignment="Left" Height="465" Margin="962,100,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="396" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="14" IsTabStop="False"/>
<Label Name="l1" Content="" HorizontalAlignment="Left" VerticalAlignment="Top" Width="599" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" FontSize="22" FontWeight="Medium" Margin="152,37,0,0" Height="44"/>
<TextBlock Name="work" Text="" HorizontalAlignment="Left" Margin="1314,10,0,0" TextWrapping="Wrap" Foreground="White" Background="Darkgreen" IsEnabled="false" Width="44" TextAlignment="Center" Height="52" VerticalAlignment="Top" FontSize="16"/>
<Button TabIndex="1" x:Name="btn_settings" Content="Standby" BorderThickness="0" HorizontalAlignment="Left" Visibility = "Hidden" Margin="1248,697,0,0" VerticalAlignment="Top" Width="119" Height="26" FontSize="13" Foreground="LightGray" Background="#292929" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_standby" Content="Standby" BorderThickness="0" HorizontalAlignment="Left" Visibility = "Hidden" Margin="1248,728,0,0" VerticalAlignment="Top" Width="119" Height="26" FontSize="13" Foreground="LightGray" Background="#292929" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_shutdown" Content="Shutdown" BorderThickness="0" HorizontalAlignment="Left" Visibility = "Hidden" Margin="1248,759,0,0" VerticalAlignment="Top" Width="119" Height="26" FontSize="13" Foreground="LightGray" Background="#292929" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_close" Content="Close" BorderThickness="0" HorizontalAlignment="Left" Visibility = "Hidden" Margin="1248,790,0,0" VerticalAlignment="Top" Width="119" Height="26" FontSize="13" Foreground="LightGray" Background="#292929" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<TextBox x:Name="chatwithme_output" Text="" BorderThickness="0" HorizontalAlignment="Left" Height="654" Margin="138,100,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="794" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="14" IsTabStop="False"/>
<TextBox TabIndex="1" x:Name="chatwithme_input" Text="" BorderThickness="0" HorizontalAlignment="Left" Height="44" Margin="138,765,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="794" IsEnabled="true" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="14" IsTabStop="False"/>
<Button TabIndex="2" x:Name="chatwithme_send" Content="Send" BorderThickness="0" HorizontalAlignment="Left" Margin="962,765,0,0" VerticalAlignment="Top" Width="100" Height="44" FontSize="20" Background="#292929" Foreground="White" FontWeight="Medium" RenderTransformOrigin="0.5,0.5"/>
<Button TabIndex="1" x:Name="btn_r710_stop" BorderThickness="0" HorizontalAlignment="Left" Margin="725,100,0,0" VerticalAlignment="Top" Width="100" Height="100" FontSize="13" Background="DarkRed" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_r710_m2" BorderThickness="0" HorizontalAlignment="Left" Margin="725,215,0,0" VerticalAlignment="Top" Width="99" Height="100" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_r710_m1" BorderThickness="0" HorizontalAlignment="Left" Margin="836,215,0,0" VerticalAlignment="Top" Width="99" Height="100" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_r710_info" BorderThickness="0" HorizontalAlignment="Left" Margin="594,100,0,0" VerticalAlignment="Top" Width="100" Height="100" FontSize="13" Background="DarkOrange" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" Name="btn_r710_start" BorderThickness="0" HorizontalAlignment="Left" Margin="836,100,0,0" VerticalAlignment="Top" Width="99" Height="100" FontSize="13" Background="DarkGreen" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
<Image x:Name="img_r710_start" Source="{Binding}"/>
</Button>
<Label Name="l1_R710" HorizontalAlignment="Left" Content="Power:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="206,98,0,0"/>
<TextBox x:Name="tb_r710_power" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="340,98,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Label Name="l2_R710" HorizontalAlignment="Left" Content="MAC:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="206,137,0,0"/>
<TextBox x:Name="tb_r710_mac" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="342,137,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Label Name="l3_R710" HorizontalAlignment="Left" Content="IP:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="206,176,0,0"/>
<TextBox x:Name="tb_r710_ip" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="342,176,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Label Name="l4_R710" HorizontalAlignment="Left" Content="BIOS:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="206,215,0,0"/>
<TextBox x:Name="tb_r710_bios" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="342,215,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Label Name="l5_R710" HorizontalAlignment="Left" Content="RAC Name:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="206,254,0,0"/>
<TextBox x:Name="tb_r710_name" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="342,254,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Button TabIndex="1" x:Name="btn_center_megstop" BorderThickness="0" HorizontalAlignment="Left" Margin="725,100,0,0" VerticalAlignment="Top" Width="100" Height="100" FontSize="13" Background="DarkRed" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_center_m2" BorderThickness="0" HorizontalAlignment="Left" Margin="725,332,0,0" VerticalAlignment="Top" Width="99" Height="100" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_center_m1" BorderThickness="0" HorizontalAlignment="Left" Margin="836,332,0,0" VerticalAlignment="Top" Width="99" Height="100" FontSize="13" Background="Gray" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_center_info" BorderThickness="0" HorizontalAlignment="Left" Margin="836,445,0,0" VerticalAlignment="Top" Width="100" Height="100" FontSize="13" Background="DarkOrange" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" Name="btn_center_megstart" BorderThickness="0" HorizontalAlignment="Left" Margin="836,100,0,0" VerticalAlignment="Top" Width="99" Height="100" FontSize="13" Background="DarkGreen" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
<Image x:Name="img_center_megstart" Source="{Binding}"/>
</Button>
<Button TabIndex="1" x:Name="btn_center_itmstop" BorderThickness="0" HorizontalAlignment="Left" Margin="725,217,0,0" VerticalAlignment="Top" Width="100" Height="100" FontSize="13" Background="DarkRed" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
</Button>
<Button TabIndex="1" x:Name="btn_center_itmstart" BorderThickness="0" HorizontalAlignment="Left" Margin="836,217,0,0" VerticalAlignment="Top" Width="99" Height="100" FontSize="13" Background="DarkGreen" FontWeight="Medium">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="0"/>
</Style>
</Button.Resources>
<Image x:Name="img_center_itmstart" Source="{Binding}"/>
</Button>
<Label Name="l1_center" HorizontalAlignment="Left" Content="Power MEG:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="127,100,0,0"/>
<TextBox x:Name="tb1_center" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="261,100,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Label Name="l2_center" HorizontalAlignment="Left" Content="Power ITM:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="127,139,0,0"/>
<TextBox x:Name="tb2_center" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="263,139,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Label Name="l3_center" HorizontalAlignment="Left" Content="Power PiHole:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="127,178,0,0"/>
<TextBox x:Name="tb3_center" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="263,178,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Label Name="l4_center" HorizontalAlignment="Left" Content="Power RPi4:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="127,217,0,0"/>
<TextBox x:Name="tb4_center" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="263,217,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Label Name="l5_center" HorizontalAlignment="Left" Content="RAC Name:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="127,256,0,0"/>
<TextBox x:Name="tb5_center" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="263,256,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
<Label x:Name="l6_center" HorizontalAlignment="Left" Content="MEG Control:&#xD;&#xA;Ryzen 7 3800X&#xD;&#xA;32GB RAM&#xD;&#xA;4TB M.2 SSD" HorizontalContentAlignment="Center" VerticalAlignment="Top" Visibility="Visible" Width="197" Height="100" FontSize="16" BorderBrush="Gray" Foreground="White" Margin="502,100,0,0"/>
<Label x:Name="l7_center" HorizontalAlignment="Left" Content="ITM Control:&#xA;I9 ???&#xA;16GB RAM&#xA;1TB SSD" HorizontalContentAlignment="Center" VerticalAlignment="Top" Visibility="Visible" Width="197" Height="100" FontSize="16" BorderBrush="Gray" Foreground="White" Margin="502,217,0,0"/>
</Grid>
</Window>
"@
# Lädt das Fenster
$window=[Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $Form))
# Objekt - Variablen Verknüpfung
#Main
$Script:menu1 = $window.findName("menu1")
$Script:menu2 = $window.findName("menu2")
$Script:menu3 = $window.findName("menu3")
$Script:menu4 = $window.findName("menu4")
$Script:menu5 = $window.findName("menu5")
$Script:menu6 = $window.findName("menu6")
$Script:img1 = $window.findName("img1")
$Script:img2 = $window.findName("img2")
$Script:img3 = $window.findName("img3")
$Script:img4 = $window.findName("img4")
$Script:img5 = $window.findName("img5")
$Script:img6 = $window.findName("img6")
$Script:btn_info = $window.findName("btninfo")
$Script:settings = $window.findName("btnsettings")
$Script:imginfo = $window.findName("imginfo")
$Script:imgsettings = $window.findName("imgsettings")
$Script:l1 = $window.findName("l1")
$Script:log = $window.findName("log")
$Script:work = $window.findName("work")
$Script:btn_standby = $window.findName("btn_standby")
$Script:btn_shutdown = $window.findName("btn_shutdown")
$Script:btn_settings = $window.findName("btn_settings")
$Script:btn_close = $window.findName("btn_close")
#KI Endpoint
$Script:chatwithme_output = $window.findName("chatwithme_output")
$Script:chatwithme_input = $window.findName("chatwithme_input")
$Script:chatwithme_send = $window.findName("chatwithme_send")
#R710
$Script:btn_r710_stop = $window.findName("btn_r710_stop")
$Script:btn_r710_start = $window.findName("btn_r710_start")
$Script:img_r710_start = $window.findName("img_r710_start")
$Script:btn_r710_info = $window.findName("btn_r710_info")
$Script:btn_r710_m1 = $window.findname("btn_r710_m1")
$Script:btn_r710_m2 = $window.findname("btn_r710_m2")
$Script:tb_r710_power = $window.findname("tb_r710_power")
$Script:tb_r710_mac = $window.findname("tb_r710_mac")
$Script:tb_r710_ip = $window.findname("tb_r710_ip")
$Script:tb_r710_bios = $window.findname("tb_r710_bios")
$Script:tb_r710_name = $window.findname("tb_r710_name")
$Script:l1_r710 = $window.findname("l1_R710")
$Script:l2_r710 = $window.findname("l2_R710")
$Script:l3_r710 = $window.findname("l3_R710")
$Script:l4_r710 = $window.findname("l4_R710")
$Script:l5_r710 = $window.findname("l5_R710")
#Center
$Script:btn_center_megstop = $window.findName("btn_center_megstop")
$Script:btn_center_megstart = $window.findName("btn_center_megstart")
$Script:img_center_megstart = $window.findName("img_center_megstart")
$Script:btn_center_info = $window.findName("btn_center_info")
$Script:btn_center_itmstop = $window.findName("btn_center_itmstop")
$Script:btn_center_itmstart = $window.findName("btn_center_itmstart")
$Script:img_center_itmstart = $window.findName("img_center_itmstart")
$Script:btn_center_m1 = $window.findname("btn_center_m1")
$Script:btn_center_m2 = $window.findname("btn_center_m2")
$Script:tb1_center = $window.findname("tb1_center")
$Script:tb2_center = $window.findname("tb2_center")
$Script:tb3_center = $window.findname("tb3_center")
$Script:tb4_center = $window.findname("tb4_center")
$Script:tb5_center = $window.findname("tb5_center")
$Script:l1_center = $window.findname("l1_center")
$Script:l2_center = $window.findname("l2_center")
$Script:l3_center = $window.findname("l3_center")
$Script:l4_center = $window.findname("l4_center")
$Script:l5_center = $window.findname("l5_center")
$Script:l6_center = $window.findname("l6_center")
$Script:l7_center = $window.findname("l7_center")
# Fensterwahl
#if (condition) {
#$window.Height="912"
#$window.Width="1370"
#$window.WindowStyle="None"
#$window.WindowState="Maximized"
#$window.Height="912"
#$window.Width="1370"
#$window.WindowStyle="SingleBorderWindow"
#$window.WindowState="Normal"
#}
# Verknüpft feste Elemente
$window.Title = $Script:Version
$window.icon="$PSScriptroot/Source/Logo.png"
$imginfo.Source = "$PSScriptroot/Source/info.png"
$imgsettings.Source = "$PSScriptroot/Source/Konfig.png"
$img1.Source = "$PSScriptroot/Source/Dash.png"
$img2.Source = "$PSScriptroot/Source/Server.png"
$img3.Source = "$PSScriptroot/Source/center.png"
$img_center_megstart.Source ="$PSScriptroot/Source/Start.png"
$img_center_itmstart.Source ="$PSScriptroot/Source/Start.png"
$img_r710_start.Source ="$PSScriptroot/Source/Start.png"
return $window
}
$Script:main = Load_main # Variable: $main
. $PSScriptRoot\GUIS\info.ps1 $PSSCriptRoot
. $PSSCriptRoot\GUIS\confirm.ps1 $PSScriptRoot
#### Definition globaler Variablen ####
## Die GO variable kann nach aufruf der confirm funktion abgefragt werden, um eine 2. Bestätigung der eingabe zu erhalten. (Aufruf: confirm $text)
[boolean]$Script:GO = $false
$Script:ScriptRoot = $PSScriptRoot
$Script:iconpath = "$PSScriptRoot\icons"
$Script:config = Import-CSV -Path "$PSScriptRoot\config.csv"
$Script:RACpath = ($config | where{$_.ID -eq "racadm_path"}).value
$Script:plinkpath = ($config | where{$_.ID -eq "plink_path"}).value
$Script:idracuser = ($config | where{$_.ID -eq "idracuser"}).value
$Script:idracpass = ($config | where{$_.ID -eq "idracpass"}).value
if($Script:idracpass -eq ""){
$idracuser = getValues "IDRAC Configurator" "Enter idrac user"
$idracpass = getValues "IDRAC Configurator" "Enter idrac password"
$NewLine = "idracuser, $idracuser" -f
$NewLine | add-content -path "$PSScriptRoot\config.csv"
$NewLine = "idracpass, $idracpass" -f
$NewLine | add-content -path "$PSScriptRoot\config.csv"
}
write-host $Script:idracuser
Write-host $Script:idracpass
#$Script:cert_path = ($config | where{$_.ID -eq "some"}).value
#$Script:defudbu_path = ($config | where{$_.ID -eq "some"}).value
$logfile = "$PSScriptRoot\log.txt"
### Farb Variablen ###
$Script:Standardbtncolor = "#00b8d4"
$Script:Delcolor = "#d50000"
$Script:BackgroundMovecolor = "#FFFFEB9C"
$Script:ForegroundMovecolor = "#FF9C6500"
$Script:Foregroundgrey = "#FF7A7A7A"
$Script:Backgroundgrey = "#FFC5C5C5"
#### Funktionen ####
### Global ###
function Write-Admin-Log{
Param($text)
"$(get-date -format "yyyy-MM-dd HH:mm:ss"): $($text)" | out-file $logfile -Append
$log.content += "$text `n"
}
function Resolve-DnsName {
param (
[Parameter(Mandatory)][string]$ComputerName
)
try {
[System.Net.Dns]::GetHostAddresses($ComputerName).IPAddressToString
return ([System.Net.Dns]::GetHostAddresses($ComputerName).IPAddressToString)
}
catch {
Write-Log "IP not found for $ComputerName!"
}
}
Function Select-FolderDialog{
param([string]$Description="Zielverzeichnis wählen",[string]$RootFolder="Desktop")
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") |Out-Null
$objForm = New-Object System.Windows.Forms.FolderBrowserDialog
$objForm.Rootfolder = $RootFolder
$objForm.Description = $Description
$Show = $objForm.ShowDialog()
If ($Show -eq "OK"){
Return $objForm.SelectedPath
}else{
Return $false
}
}
function working {
param (
$status
)
if ($status) {
$Script:work.Background="Darkred"
}else {
$Script:work.Background="Darkgreen"
}
}
#### Startet die Anwendung ####
### Initialisieren ###
$Script:btn_info.Add_Click({
$Script:info.ShowDialog()
})
### Settings ###
$settings.Add_Click({
if ($Script:array[0]) {
$Script:btn_settings.Visibility = "Hidden"
$Script:btn_standby.Visibility = "Hidden"
$Script:btn_shutdown.Visibility = "Hidden"
$Script:btn_close.Visibility = "Hidden"
$Script:array[0]=$false
}else {
$Script:btn_settings.Visibility = "Visible"
$Script:btn_standby.Visibility = "Visible"
$Script:btn_shutdown.Visibility = "Visible"
$Script:btn_close.Visibility = "Visible"
$Script:array[0]=$true
}
})
$Script:btn_settings.Add_Click({
})
$Script:btn_standby.Add_Click({
if (confirm "Wanna SUSPEND the System?") {
$PowerState = [System.Windows.Forms.PowerState]::Suspend
$Force = $false
$DisableWake = $false
[System.Windows.Forms.Application]::SetSuspendState($PowerState, $Force, $DisableWake)
}
})
$Script:btn_shutdown.Add_Click({
if (confirm "Wanna SHUTDOWN the System?") {
$PowerState = [System.Windows.Forms.PowerState]::Shutdown
$Force = $false
$DisableWake = $false
[System.Windows.Forms.Application]::SetSuspendState($PowerState, $Force, $DisableWake)
}
})
$Script:btn_close.Add_Click({
$main.Hide()
})
### Menu ###
function clearGUI {
#KI
$Script:chatwithme_output.Visibility = "Hidden"
$Script:chatwithme_input.Visibility = "Hidden"
$Script:chatwithme_send.Visibility = "Hidden"
#R710
$Script:btn_r710_stop.Visibility = "Hidden"
$Script:btn_r710_start.Visibility = "Hidden"
$Script:btn_r710_info.Visibility = "Hidden"
$Script:btn_r710_m1.Visibility = "Hidden"
$Script:btn_r710_m2.Visibility = "Hidden"
$Script:tb_r710_power.Visibility = "Hidden"
$Script:tb_r710_mac.Visibility = "Hidden"
$Script:tb_r710_ip.Visibility = "Hidden"
$Script:tb_r710_bios.Visibility = "Hidden"
$Script:tb_r710_name.Visibility = "Hidden"
$Script:l1_r710.Visibility = "Hidden"
$Script:l2_r710.Visibility = "Hidden"
$Script:l3_r710.Visibility = "Hidden"
$Script:l4_r710.Visibility = "Hidden"
$Script:l5_r710.Visibility = "Hidden"
#Center
$Script:btn_center_megstop.Visibility = "Hidden"
$Script:btn_center_megstart.Visibility = "Hidden"
$Script:btn_center_info.Visibility = "Hidden"
$Script:btn_center_itmstop.Visibility = "Hidden"
$Script:btn_center_itmstart.Visibility = "Hidden"
$Script:btn_center_m1.Visibility = "Hidden"
$Script:btn_center_m2.Visibility = "Hidden"
$Script:tb1_center.Visibility = "Hidden"
$Script:tb2_center.Visibility = "Hidden"
$Script:tb3_center.Visibility = "Hidden"
$Script:tb4_center.Visibility = "Hidden"
$Script:tb5_center.Visibility = "Hidden"
$Script:l1_center.Visibility = "Hidden"
$Script:l2_center.Visibility = "Hidden"
$Script:l3_center.Visibility = "Hidden"
$Script:l4_center.Visibility = "Hidden"
$Script:l5_center.Visibility = "Hidden"
$Script:l6_center.Visibility = "Hidden"
$Script:l7_center.Visibility = "Hidden"
}
function SwitchGUI {
param (
$menu
)
if ($menu -match "m1") {
clearGUI
$Script:chatwithme_output.Visibility = "Visible"
$Script:chatwithme_input.Visibility = "Visible"
$Script:chatwithme_send.Visibility = "Visible"
}elseif ($menu -match "m2") {
clearGUI
$Script:btn_r710_stop.Visibility = "Visible"
$Script:btn_r710_start.Visibility = "Visible"
$Script:btn_r710_info.Visibility = "Visible"
$Script:btn_r710_m1.Visibility = "Visible"
$Script:btn_r710_m2.Visibility = "Visible"
$Script:tb_r710_power.Visibility = "Visible"
$Script:tb_r710_mac.Visibility = "Visible"
$Script:tb_r710_ip.Visibility = "Visible"
$Script:tb_r710_bios.Visibility = "Visible"
$Script:tb_r710_name.Visibility = "Visible"
$Script:l1_r710.Visibility = "Visible"
$Script:l2_r710.Visibility = "Visible"
$Script:l3_r710.Visibility = "Visible"
$Script:l4_r710.Visibility = "Visible"
$Script:l5_r710.Visibility = "Visible"
}elseif ($menu -match "m3") {
clearGUI
$Script:btn_center_megstop.Visibility = "Visible"
$Script:btn_center_megstart.Visibility = "Visible"
$Script:btn_center_info.Visibility = "Visible"
$Script:btn_center_itmstop.Visibility = "Visible"
$Script:btn_center_itmstart.Visibility = "Visible"
$Script:btn_center_m1.Visibility = "Visible"
$Script:btn_center_m2.Visibility = "Visible"
$Script:tb1_center.Visibility = "Visible"
$Script:tb2_center.Visibility = "Visible"
$Script:tb3_center.Visibility = "Visible"
$Script:tb4_center.Visibility = "Visible"
$Script:tb5_center.Visibility = "Visible"
$Script:l1_center.Visibility = "Visible"
$Script:l2_center.Visibility = "Visible"
$Script:l3_center.Visibility = "Visible"
$Script:l4_center.Visibility = "Visible"
$Script:l5_center.Visibility = "Visible"
$Script:l6_center.Visibility = "Visible"
$Script:l7_center.Visibility = "Visible"
}elseif ($menu -match "m4") {
clearGUI
}elseif ($menu -match "m5") {
clearGUI
}elseif ($menu -match "m6") {
clearGUI
}
}
$Script:menu1.Add_Click({
switchGUI -menu "m1"
$Script:l1.Content = "Local LLM"
})
$Script:menu2.Add_Click({
switchGUI -menu "m2"
$Script:l1.Content = "R710 Control"
})
$Script:menu3.Add_Click({
switchGUI -menu "m3"
$Script:l1.Content = "Gaming Control"
})
$Script:menu4.Add_Click({
switchGUI -menu "m4"
})
$Script:menu5.Add_Click({
switchGUI -menu "m5"
})
$Script:menu6.Add_Click({
switchGUI -menu "m6"
})
### ChatWithMe ###
$Script:chatwithme_input.Add_KeyDown({
if ($_.Key -eq "Enter") {
$payload = @{
model="Mini Orca (Small)"
messages = @(@{
role = "user"
content = "$($Script:chatwithme_input.text)"
}
)
max_tokens = 2048
temperature = 0.7
}
$json = ($payload | ConvertTo-Json -Depth 6 -compress)
$response = (Invoke-WebRequest -URI http://192.168.178.182:4891/v1/chat/completions -Method POST -ContentType application/json -Body $json)
$content = $response.Content
$index = ($content.IndexOf("content"))+10
$second_index = $content.Substring($index).IndexOf("role")-3
$cutdown= $content.Substring($index, $second_index)
$Script:chatwithme_output.Text = $cutdown.replace("/n", "&#xD;&#xA;")
}
})
$Script:chatwithme_send.Add_Click({
$payload = @{
model="Mini Orca (Small)"
messages = @(@{
role = "user"
content = "$($Script:chatwithme_input.text)"
}
)
max_tokens = 2048
temperature = 0.7
}
$json = ($payload | ConvertTo-Json -Depth 6 -compress)
$response = (Invoke-WebRequest -URI http://192.168.178.182:4891/v1/chat/completions -Method POST -ContentType application/json -Body $json)
$content = $response.Content
$index = ($content.IndexOf("content"))+10
$second_index = $content.Substring($index).IndexOf("role")-3
$cutdown= $content.Substring($index, $second_index)
$Script:chatwithme_output.Text = $cutdown.replace("/n", "&#xD;&#xA;")
})
### R710 ###
function get_r710_stats {
working $true
cd $Script:racpath
$collection = $(.\racadm.exe -r spaeth-bayern.de:5005 -u root -p "kt}y/6ZHF~.@" getsysinfo)
foreach ($item in $collection) {
if ($null -ne $item) {
$log.Text += "$item`n"
if($item -match "DNS RAC Name"){
$index = ($item.IndexOf("="))
$Script:tb_r710_name.Text = $item.Substring($index+1)
}
if($item -match "Firmware Version"){
$index = ($item.IndexOf("="))
$Script:tb_r710_bios.Text = $item.Substring($index+1)
}
if($item -match "Power Status"){
$index = ($item.IndexOf("="))
$Script:tb_r710_power.Text = $item.Substring($index+1)
}
if($item -match "MAC Address"){
$index = ($item.IndexOf("="))
$Script:tb_r710_mac.Text = $item.Substring($index+1)
}
if($item -match "Power Status"){
$index = ($item.IndexOf("="))
$Script:tb_r710_power.Text = $item.Substring($index+1)
}
}
}
cd $PSSCriptRoot
working $false
}
$btn_r710_start.Add_Click({
Write-Admin-Log "BTN r710 start pressed"
if (confirm "Server R710 wird durch erneute betätigung gestartet") {
cd $racpath
$r710_log.Text += $(.\racadm.exe -r spaeth-bayern.de:5005 -u root -p "kt}y/6ZHF~.@" serveraction powerup)
}
})
$btn_r710_stop.Add_Click({
Write-Admin-Log "BTN r710 stop pressed"
if (confirm "Server R710 wird durch erneute betätigung gestopt`n`nSind alle Virtuelle Maschinen ausgeschaltet?") {
cd $Script:racpath
$r710_log.Text += $(.\racadm.exe -r spaeth-bayern.de:5005 -u root -p "kt}y/6ZHF~.@" serveraction powerdown)
}
})
$btn_r710_info.Add_Click({
Write-Admin-Log "BTN r710 inspect pressed"
get_r710_stats
})
#Center
$Script:btn_center_itmstart.Add_Click({
$Password = "Ob>Q%T\;Cf(9\+T+-7lNQl*i*)(3;Egl"
$servername = '192.168.178.4'
$username = 'spaethf'
Write-Admin-Log "BTN ITM pressed"
if (confirm "Bei dem Server gaming Server ITM wird eine Power Aktion ausgeführt") {
$command = 'python tap_itm.py'
#Execute SSH command
echo y | &($plinkpath + "\plink.exe") -pw $password $username@$servername $command
}
})
$Script:btn_center_itmstop.Add_Click({
$Password = "Ob>Q%T\;Cf(9\+T+-7lNQl*i*)(3;Egl"
$servername = '192.168.178.4'
$username = 'spaethf'
Write-Admin-Log "BTN ITM pressed"
if (confirm "Bei dem Server gaming Server ITM wird eine Power Aktion ausgeführt") {
$command = 'python tap_itm.py'
#Execute SSH command
echo y | &($plinkpath + "\plink.exe") -pw $password $username@$servername $command
}
})
$Script:btn_center_megstart.Add_Click({
$Password = "Ob>Q%T\;Cf(9\+T+-7lNQl*i*)(3;Egl"
$servername = '192.168.178.4'
$username = 'spaethf'
Write-Admin-Log "BTN MEG pressed"
if (confirm "Bei dem Server gaming Server MEG wird eine Power Aktion ausgeführt") {
$command = 'python tap_meg.py'
#Execute SSH command
echo y | &($plinkpath + "\plink.exe") -pw $password $username@$servername $command
}
})
$Script:btn_center_megstop.Add_Click({
$Password = "Ob>Q%T\;Cf(9\+T+-7lNQl*i*)(3;Egl"
$servername = '192.168.178.4'
$username = 'spaethf'
Write-Admin-Log "BTN MEG pressed"
if (confirm "Bei dem Server gaming Server MEG wird eine Power Aktion ausgeführt") {
$command = 'python tap_meg.py'
#Execute SSH command
echo y | &($plinkpath + "\plink.exe") -pw $password $username@$servername $command
}
})
### Öffnet erstes Fenster ###
Write-Admin-Log "##### OPEN MAIN WINDOW #####"
clearGUI
switchGUI "m1"
$main.ShowDialog() | Out-Null