Jump to content

Granatelbart

Members
  • Gesamte Inhalte

    2
  • Registriert seit

  • Letzter Besuch

Fortschritt von Granatelbart

Newbie

Newbie (1/14)

  • Eine Woche dabei
  • Erste Antwort
  • Erster eigener Beitrag

Neueste Abzeichen

0

Reputation in der Community

  1. ja ich muss das Skript noch etwas aufräumen ist mir bewusst (mit unter weil ich am testen bin) Diese genannten "Fehler" sind aber auch nicht mein derzeitiges Problem Setze Strings immer in ' oder ". <<<< Das weiß ich wohl ist halt beim ersetzen durch * entfernt worden [void] [System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') [void] [System.Reflection.Assembly]::LoadWithPartialName('System.Drawing') [void] [System.Windows.Forms.Application]::EnableVisualStyles() $WindowTitle = 'Certified-Bots Arkmanager' $Title = 'Certified-Bots Arkmanager' $Password = "++++++++++" $User = "+++++++++" $ComputerName = "+++++++++" $Results = Invoke-SSHCommand -SessionId 0 -Command "arkmanager list-instances | cut -f1 -d ':' --output-delimiter=' ' " echo $Results|select -ExpandProperty Output | Format-List | Out-File -FilePath c:\test\Process.txt # Main menu $MenuBox = New-Object System.Windows.Forms.Form $MenuBox.Size = New-Object System.Drawing.Size @(650,450) $MenuBox.Text = $WindowTitle $MenuBox.StartPosition = 'CenterScreen' $MenuBox.MaximizeBox = $False $MenuBox.AutoSize = $False $MenuBox.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D $MenuBox.BackgroundImageLayout = 'None' # None, Tile, Center, Stretch, Zoom # Exit Button $ExitButton = New-Object System.Windows.Forms.Button $ExitButton.Location = New-Object System.Drawing.Size(540,370) $ExitButton.Size = New-Object System.Drawing.Size(75,23) $ExitButton.Text = 'Exit' $ExitButton.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",11,0,3,1) $ExitButton.Add_Click({ $MenuBox.Close() }) # Exit Button $ExitButton1 = New-Object System.Windows.Forms.Button $ExitButton1.Location = New-Object System.Drawing.Size(540,370) $ExitButton1.Size = New-Object System.Drawing.Size(75,23) $ExitButton1.Text = 'Exit' $ExitButton1.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",11,0,3,1) $ExitButton1.Add_Click({ $Backup.Close() }) # Exit Button $ExitButton2 = New-Object System.Windows.Forms.Button $ExitButton2.Location = New-Object System.Drawing.Size(540,370) $ExitButton2.Size = New-Object System.Drawing.Size(75,23) $ExitButton2.Text = 'Exit' $ExitButton2.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",11,0,3,1) $ExitButton2.Add_Click({ $ADBox.Close() }) # Main menu Header Text $MenuHeader = New-Object System.Windows.Forms.Label $MenuHeader.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",14,1,3,1) $MenuHeader.Location = New-Object System.Drawing.Size(118,20) $MenuHeader.Size = New-Object System.Drawing.Size(380,40) $MenuHeader.Text = $Title $MenuHeader.BackColor = 'Transparent' $MenuHeader.TextAlign = [System.Drawing.ContentAlignment]::TopCenter $MenuBox.Controls.Add($MenuHeader) # Main menu $BoxLabel = New-Object System.Windows.Forms.Label $BoxLabel.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",10,0,3,1) $BoxLabel.Location = New-Object System.Drawing.Size(10,60) $BoxLabel.Size = New-Object System.Drawing.Size(680,20) $BoxLabel.Text = 'Select the category:' $BoxLabel.BackColor = 'Transparent' $MenuBox.Controls.Add($BoxLabel) # AD menu $ADBox = New-Object System.Windows.Forms.Form $ADBox.Size = New-Object System.Drawing.Size @(650,450) $ADBox.Text = $WindowTitle $ADBox.StartPosition = 'CenterParent' $ADBox.AutoSize = $False $ADBox.MaximizeBox = $False $ADBox.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D # Backup menu $Backup = New-Object System.Windows.Forms.Form $Backup.Size = New-Object System.Drawing.Size @(650,450) $Backup.Text = $WindowTitle $Backup.StartPosition = 'CenterParent' $Backup.AutoSize = $False $Backup.MaximizeBox = $False $Backup.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D #######Restart Menü######### $Button2 = New-Object System.Windows.Forms.Button $Button2.Location = New-Object System.Drawing.Size(62,100) $Button2.Size = New-Object System.Drawing.Size(500,30) $Button2.Add_Click({ # Call Sub menu 1 $MenuBox.Close() $MenuBox.Dispose() $ADBox.Topmost = $True $ADBox.Add_Shown({$ADBox.Activate()}) [void] $ADBox.ShowDialog() }) $Button2.Text = 'Server Restart' $Button2.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,0,3,1) $MenuBox.Controls.Add($Button2) $MenuBox.Controls.Add($ExitButton1) $form=New-Object System.Windows.Forms.Form $arguments = get-content c:\test\Process.txt $i=0 foreach ($arg in $arguments){ $b=New-Object System.Windows.Forms.Button $b.Name=$arg $b.location="62,$(40*++$I)" $b.Size = New-Object System.Drawing.Size(500,30) $b.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,0,3,1) $b.Text=$arg $Button_Click1 = {write-host "Restart $arg"} $b.Add_Click($Button_Click1) $ADBox.Controls.Add($b) $ADBox.Controls.Add($ExitButton2) } #############BACKUP########### # Main menu button 2 $Button1 = New-Object System.Windows.Forms.Button $Button1.Location = New-Object System.Drawing.Size(62,140) $Button1.Size = New-Object System.Drawing.Size(500,30) $Button1.Add_Click({ # Call Sub menu 1 $MenuBox.Close() $MenuBox.Dispose() $Backup.Topmost = $True $Backup.Add_Shown({$Backup.Activate()}) [void] $Backup.ShowDialog() }) $Button1.Text = 'Server Backup' $Button1.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,0,3,1) $MenuBox.Controls.Add($Button1) $MenuBox.Controls.Add($ExitButton) $form=New-Object System.Windows.Forms.Form $arguments1 = get-content c:\test\Process.txt $i=0 foreach ($arg1 in $arguments1){ $b=New-Object System.Windows.Forms.Button $b.Name=$arg $b.location="62,$(40*++$I)" $b.Size = New-Object System.Drawing.Size(500,30) $b.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,0,3,1) $b.Text=$arg1 $b.Tag=$arg1 $button_click2 = {write-host "Backup $arg1"} $b.Add_Click($Button_Click2) $form.controls.add($b) $Backup.Controls.Add($b) $Backup.Controls.Add($ExitButton1) $Backup.Controls.Add($BackButton) } # Show Menu $MenuBox.Topmost = $True $MenuBox.Add_Shown({$MenuBox.Activate()}) [void] $MenuBox.ShowDialog() Mein Problem liegt eher in diesem Bereich. Ich generiere immer nur das Gleiche Event für die unterschiedlichen Button
  2. Guten Tag, ich versuche aktuell ein dynamisches Menü aus einer TXT zu erstellen. Das Menü baut sich soweit korrekt zusammen jedoch passen sich die Click-Button nicht an. [void] [System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') [void] [System.Reflection.Assembly]::LoadWithPartialName('System.Drawing') [void] [System.Windows.Forms.Application]::EnableVisualStyles() $WindowTitle = '*********' $Title = '********' $Icon = [system.drawing.icon]::ExtractAssociatedIcon($PSHOME + "\powershell.exe") $Password = ******* $User = ****** $ComputerName = ******** $Command = "SSH Command" $secpasswd = ConvertTo-SecureString $Password -AsPlainText -Force $Credentials = New-Object System.Management.Automation.PSCredential($User, $secpasswd) $SessionID = New-SSHSession -ComputerName $ComputerName -Credential $Credentials -AcceptKey $Results = Invoke-SSHCommand -SessionId 0 -Command "****** list-instances | cut -f1 -d ':' --output-delimiter=' ' " echo $Results|select -ExpandProperty Output | Format-List | Out-File -FilePath c:\test\Process.txt # Main menu $MenuBox = New-Object System.Windows.Forms.Form $MenuBox.Size = New-Object System.Drawing.Size @(650,450) $MenuBox.Text = $WindowTitle $MenuBox.StartPosition = 'CenterScreen' $MenuBox.MaximizeBox = $False $MenuBox.AutoSize = $False $MenuBox.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D $MenuBox.Icon = $Icon $MenuBox.BackgroundImage = $Image $MenuBox.BackgroundImageLayout = 'None' # None, Tile, Center, Stretch, Zoom # Exit Button $ExitButton = New-Object System.Windows.Forms.Button $ExitButton.Location = New-Object System.Drawing.Size(540,370) $ExitButton.Size = New-Object System.Drawing.Size(75,23) $ExitButton.Text = 'Exit' $ExitButton.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",11,0,3,1) $ExitButton.Add_Click({ $MenuBox.Close() }) # Main menu Header Text $MenuHeader = New-Object System.Windows.Forms.Label $MenuHeader.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",14,1,3,1) $MenuHeader.Location = New-Object System.Drawing.Size(118,20) $MenuHeader.Size = New-Object System.Drawing.Size(380,40) $MenuHeader.Text = $Title $MenuHeader.BackColor = 'Transparent' $MenuHeader.TextAlign = [System.Drawing.ContentAlignment]::TopCenter $MenuBox.Controls.Add($MenuHeader) # Main menu $BoxLabel = New-Object System.Windows.Forms.Label $BoxLabel.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",10,0,3,1) $BoxLabel.Location = New-Object System.Drawing.Size(10,60) $BoxLabel.Size = New-Object System.Drawing.Size(680,20) $BoxLabel.Text = 'Select the category:' $BoxLabel.BackColor = 'Transparent' $MenuBox.Controls.Add($BoxLabel) # AD menu $ADBox = New-Object System.Windows.Forms.Form $ADBox.Size = New-Object System.Drawing.Size @(650,450) $ADBox.Text = $WindowTitle $ADBox.StartPosition = 'CenterParent' $ADBox.AutoSize = $False $ADBox.MaximizeBox = $False $ADBox.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D $ADBox.Icon = $Icon $ADBox.BackgroundImage = $Image # AD menu $Backup = New-Object System.Windows.Forms.Form $Backup.Size = New-Object System.Drawing.Size @(650,450) $Backup.Text = $WindowTitle $Backup.StartPosition = 'CenterParent' $Backup.AutoSize = $False $Backup.MaximizeBox = $False $Backup.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D $Backup.Icon = $Icon $Backup.BackgroundImage = $Image # install menu $install = New-Object System.Windows.Forms.Form $install.Size = New-Object System.Drawing.Size @(650,450) $install.Text = $WindowTitle $install.StartPosition = 'CenterParent' $install.AutoSize = $False $install.MaximizeBox = $False $install.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::Fixed3D $install.Icon = $Icon $install.BackgroundImage = $Image #######Restart Menü######### # Main menu button 1 # Main menu button 2 $Button2 = New-Object System.Windows.Forms.Button $Button2.Location = New-Object System.Drawing.Size(62,100) $Button2.Size = New-Object System.Drawing.Size(500,30) $Button2.Add_Click({ # Call Sub menu 1 $MenuBox.Close() $MenuBox.Dispose() $ADBox.Topmost = $True $ADBox.Add_Shown({$ADBox.Activate()}) [void] $ADBox.ShowDialog() }) $Button2.Text = 'Server Restart' $Button2.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,0,3,1) $MenuBox.Controls.Add($Button2) $MenuBox.Controls.Add($ExitButton) $form=New-Object System.Windows.Forms.Form function function-to-run{ $this.ForeColor=$this.Tag write-host $this.Tag -fore $this.Tag -back white } $arguments = get-content c:\test\Process.txt $i=0 foreach ($arg in $arguments){ $b=New-Object System.Windows.Forms.Button $b.Name=$arg $b.location="62,$(40*++$I)" $b.Size = New-Object System.Drawing.Size(500,30) $b.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",12,0,3,1) $b.Text="$arg" $b.Tag=$arg $b.Add_Click($Button_Click) $button_click = {write-host "hi $arg"} $form.controls.add($b) $ADBox.Controls.Add($b) $ADBox.Controls.Add($ExitButton1) } # Show Menu $MenuBox.Topmost = $True $MenuBox.Add_Shown({$MenuBox.Activate()}) [void] $MenuBox.ShowDialog()
×
×
  • Neu erstellen...