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

776 lines
35 KiB
PowerShell

$Script:Version = "FS Admin Panel v0.8 (extern)"
#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
}
Function Select-FolderDialog{
param([string]$Description="RACADM Speicherort 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
}
}
### $schema = getValues "Database Schema" "Enter database schema"
#### Lädt Scripte ####
function Load_info {
[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:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:winForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Name="Window" Title="Cleaner - Information" Height="440" Width="624" Icon="{Binding Icon}" ResizeMode="NoResize" WindowStyle="None">
<Grid Background="#00344E">
<TextBlock Name="text" Text="" HorizontalAlignment="Left" Margin="34,44,0,0" TextWrapping="Wrap" Foreground="White" Width="554" TextAlignment="Center" Height="360" VerticalAlignment="Top" FontSize="16"></TextBlock>
<Button Name="btnok" Content="OK" HorizontalAlignment="Left" Margin="264,390,0,0" VerticalAlignment="Top" Width="100" Height="36" BorderThickness="0" Background="#00b8d4" Foreground="White">
<Button.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="2"/>
</Style>
</Button.Resources>
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Label Content="Information" HorizontalAlignment="Left" VerticalAlignment="Top" Width="624" HorizontalContentAlignment="Center" Foreground="White" FontSize="20" FontWeight="Bold"/>
</Grid>
</Window>
"@
# Lädt das Fenster
$window=[Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $Form))
$NR=(New-Object System.Xml.XmlNodeReader $Form)
$window=[Windows.Markup.XamlReader]::Load($NR)
# Objekt - Variablen Verknüpfung
$text = $window.FindName("text")
$Script:infook = $window.findName("btnok")
# Verknüpft feste Elemente
$window.Title = $Script:Version
$window.icon="C:\FSAP/Source/Logo.png"
$text.Text = "Das Admin Panel wurde geschaffen um Skripte welche von dem einzig waren Florian Spaeth entwickelt wurden in einer grafischen Oberfläche zu steuern.
Die Anwendung wurde so entworfen das diese maximale Wartungsfreundlichkeit bietet und auch Usern mit wenig Powershell Erfahrung die Möglichkeit gibt, neue Fenster hinzu zu fügen.
Im GitLab unter `"AllgemeineSkripte/examples`" kann Beispiel Code entnommen werden, wenn man sind in den BR hacken kann (: `n`nBugs in der GUI werden nicht aktiv verfolgt!`n`n$Script:Version `nCopyright bei Leiter (2024)`nAutor: Florian Spaeth `nDSGVO-Konform"
return $window
}
function Load_confirm {
[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"
Name="Window" Title="HDS Admin Panel - Confirm" Height="276" Width="509" Icon="{Binding Icon}" ResizeMode="NoResize" WindowStyle="None">
<Grid Background="#00344E">
<Button Name="btnstop" Content="BACK" HorizontalAlignment="Left" Margin="122,215,0,0" VerticalAlignment="Top" Width="100" Height="36" BorderThickness="0" Background="DarkGreen" Foreground="White">
<Button.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="2"/>
</Style>
</Button.Resources>
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Label Content="Confirm" HorizontalAlignment="Left" VerticalAlignment="Top" Width="509" HorizontalContentAlignment="Center" Foreground="White" FontSize="20" FontWeight="Bold"/>
<Label Name="choosen3" Content="Confirm the action and press the button again" HorizontalAlignment="Center" Margin="0,42,0,0" VerticalAlignment="Top" Width="270" Height="34" FontSize="12" FontWeight="Bold" Foreground="White"/>
<TextBox Name="text" Text="TEXT" BorderThickness="0" HorizontalAlignment="Center" Height="113" TextWrapping="Wrap" VerticalAlignment="Center" Width="412" Background="#013C5A" HorizontalContentAlignment="Center" Foreground="White" FontSize="14" IsTabStop="False"/>
<Button Name="btngo" Content="GO!" HorizontalAlignment="Left" Margin="286,215,0,0" VerticalAlignment="Top" Width="100" Height="36" BorderThickness="0" Background="DarkRed" Foreground="White">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="2"/>
</Style>
</Button.Resources>
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</Grid>
</Window>
"@
# Lädt das Fenster
$window=[Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $Form))
$NR=(New-Object System.Xml.XmlNodeReader $Form)
$window=[Windows.Markup.XamlReader]::Load($NR)
# Objekt - Variablen Verknüpfung
$Script:confirmtext = $window.FindName("text")
$Script:confirmok = $window.findName("btngo")
$Script:confirmstop = $window.findName("btnstop")
# Verknüpft feste Elemente
$window.Title = $Script:Version
$window.icon="C:\FSAP/Source/Logo.png"
return $window
}
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="770" Width="932" Background="#1a1a1a" ResizeMode="NoResize">
<Grid>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Width="108" Height="731" 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"/>
<Button TabIndex="1" Name="menu1" BorderThickness="0" HorizontalAlignment="Left" Margin="20,101,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,191,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,281,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,374,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,467,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,559,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,664,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="834,653,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="505,101,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="Settings" BorderThickness="0" HorizontalAlignment="Left" Margin="738,478,0,0" Visibility = "Hidden" VerticalAlignment="Top" Width="163" Height="35" 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" Margin="738,519,0,0" Visibility = "Hidden" VerticalAlignment="Top" Width="163" Height="35" 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" Margin="738,561,0,0" Visibility = "Hidden" VerticalAlignment="Top" Width="163" Height="35" 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" Margin="738,602,0,0" Visibility = "Hidden" VerticalAlignment="Top" Width="163" Height="35" 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_r710_stop" BorderThickness="0" HorizontalAlignment="Left" Margin="268,316,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="268,431,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="379,431,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="137,316,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="379,316,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>
</Button>
<Label Name="l1_R710" HorizontalAlignment="Left" Content="Power:" VerticalAlignment="Top" Visibility="Visible" Width="128" Height="34" FontSize="18" BorderBrush="Gray" Foreground="White" Margin="124,100,0,0"/>
<TextBox x:Name="tb_r710_power" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="260,100,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="124,139,0,0"/>
<TextBox x:Name="tb_r710_mac" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="260,139,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="124,178,0,0"/>
<TextBox x:Name="tb_r710_ip" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="260,178,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="124,217,0,0"/>
<TextBox x:Name="tb_r710_bios" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="260,217,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="124,256,0,0"/>
<TextBox x:Name="tb_r710_name" Text="" BorderThickness="0" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="34" Margin="260,256,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="220" IsEnabled="false" HorizontalContentAlignment="Center" Background="#292929" Foreground="White" FontSize="16" IsTabStop="False"/>
</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")
#Dashboard
$Script:Dashboard = $window.findName("Dashboard")
#R710
$Script:btn_r710_stop = $window.findName("btn_r710_stop")
$Script:btn_r710_start = $window.findName("btn_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")
# 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="C:\FSAP\Source\Logo.png"
$imginfo.Source = "C:\FSAP\Source\info.png"
$imgsettings.Source = "C:\FSAP/Source/Konfig.png"
$img1.Source = "C:\FSAP/Source/Dash.png"
$img2.Source = "C:\FSAP/Source/Server.png"
$img3.Source = "C:\FSAP/Source/center.png"
return $window
}
$Script:main = Load_main # Variable: $main
$Script:confirm = Load_confirm # Variable: $confirm
$Script:info = Load_info # Variable: $info
#### 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 = "C:\FSAP"
$Script:iconpath = "C:\FSAP\icons"
$Script:config = Import-CSV -Path "C:\FSAP\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
$Script:remoteuser = ($config | where{$_.ID -eq "remoteuser"}).value
$Script:remotepass = ($config | where{$_.ID -eq "remotepass"}).value
$idracpassenc = "$Script:idracpass"|ConvertTo-SecureString
$Script:idracpass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($idracpassenc))
$remotepassenc = "$Script:remotepass"|ConvertTo-SecureString
$Script:remotepass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($remotepassenc))
#$Script:cert_path = ($config | where{$_.ID -eq "some"}).value
#$Script:defudbu_path = ($config | where{$_.ID -eq "some"}).value
$logfile = "C:\FSAP\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
$Script:log.text += "$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 working {
param (
$status
)
if ($status) {
$Script:work.Background="Darkred"
}else {
$Script:work.Background="Darkgreen"
}
}
function confirm {
param (
[String]$text
)
Write-Admin-Log "Confirm funkction triggered"
if ($null -ne $text) {
$Script:Confirmtext.text = $text
$confirm.ShowDialog() | Out-Null
if ($Script:GO) {
return $true
}
}
}
$confirmok.Add_Click({
Write-Admin-Log "Confirm success"
$Script:GO = $true
$confirm.Hide()
})
$confirm.Add_MouseLeftButtonDown({
$confirm.DragMove()
})
$confirmstop.Add_Click({
Write-Admin-Log "Confirm denial"
$Script:GO = $false
$confirm.Hide()
})
#### 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({
$return = Select-FolderDialog
if($return){
$Script:racpath = $return
$NewLine = "racadm_path, $racpath" -f
$NewLine | add-content -path "C:\FSAP\config.csv"
}
$Script:idracuser = getValues "IDRAC Configurator" "Enter idrac user"
$Script:idracpass = getValues "IDRAC Configurator" "Enter idrac password"
$Script:remoteuser = getValues "IDRAC Configurator" "Enter remote user"
$Script:remotepass = getValues "IDRAC Configurator" "Enter remote password"
$NewLine = "idracuser, $idracuser" -f
$NewLine | add-content -path "C:\FSAP\config.csv"
$secidracpass = "$idracpass" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString
$NewLine = "idracpass, $secidracpass" -f
$NewLine | add-content -path "C:\FSAP\config.csv"
$NewLine = "remoteuser, $remoteuser" -f
$NewLine | add-content -path "C:\FSAP\config.csv"
$secremotepass = "$remotepass" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString
$NewLine = "remotepass, $secremotepass" -f
$NewLine | add-content -path "C:\FSAP\config.csv"
write-host $Script:remoteuser
Write-host $Script:remotepass
})
$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()
})
$info.Add_MouseLeftButtonDown({
$info.DragMove()
})
$infook.Add_Click({
$Script:info.Hide()
})
### Menu ###
function clearGUI {
#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"
}
function SwitchGUI {
param (
$menu
)
if ($menu -match "m1") {
clearGUI
}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
}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 = "Dashboard"
})
$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"
})
### R710 ###
function get_r710_stats {
working $true
cd $Script:racpath
$collection = $(.\racadm.exe -r spaeth-bayern.de:5005 -u $Script:idracuser -p $Script:idracpass 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 C:\FSAP
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 $Script:idracuser -p $Script:idracpass 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`nIST DER SERVER HERUNTERGEFAHREN (/STOP IN DIE MINECRAFT CONSOLE)?") {
$command = './stop_proxmox.sh'
#Execute SSH command
echo y | &($plinkpath + "\plink.exe") -pw "$Script:remotepass" "$Script:remoteuser@spaeth-bayern.de" $command
#cd $Script:racpath
#$r710_log.Text += $(.\racadm.exe -r spaeth-bayern.de:5005 -u $Script:idracuser -p $Script:idracpass serveraction powerdown)
}
})
$btn_r710_info.Add_Click({
Write-Admin-Log "BTN r710 inspect pressed"
if (confirm "Server R710 wird nach grundlegenden Infromationen abgefragt.`n`nDie Abfrage kann bis zu 2 min. dauern.") {
get_r710_stats
}
})
### Öffnet erstes Fenster ###
Write-Admin-Log "##### OPEN MAIN WINDOW #####"
clearGUI
switchGUI "m1"
Write-Host $remotepass
$main.ShowDialog() | Out-Null