#------------------------------------------------------------------------ # Source File Information (DO NOT MODIFY) # Source ID: cfd5eaf9-beed-4b19-b790-f40186f5782a # Source File: test-tools.psf #------------------------------------------------------------------------ #region File Recovery Data (DO NOT MODIFY) <#RecoveryData: Gw8AAB+LCAAAAAAABADVl19v2jAUxd8n7TtEeWZAApQyhUglbaVp7VqNrtsbcpxL69WxkeO0ZJ9+ dgKUQWicliJNSCh/jnOP/Ts3VrzvgPkjiOwUSWSpg4RwNrTdpmP7Hz9YlnclyB1hiJ4TCt9QDL6E RH6SnNOkOUumXmtLUAwLfwOWlsxmMLTHWSIhbv4kLOJPSfOci7j4b1hltxrW7cJHt9nWv4YVpFSm AoYMUikQbVjXaUgJ/grZDX8ANgz7fdTDvSNn0OlC+3hgW0xZGdpT9TzHtvA9oZFQOjvgTArlvZid Mnot+AyEzBYDTlLJxxhROCUxMG1CSY8altPxWktp1dBLHoHtn6tKlWMCSoDJMfmjBvSdbsPqOm7l IL3Ktp9PrVJ7A3OpvYh4W3r2qGovdBccRYtnTvSx18rvLqXVOC9QCPTdeY5BqIy+BHQHl3yFb0QK W8uwPeCCYySVXdt3XEV+G8guJIU7A3lhp+uU5qoEIgq/sAjmKokm6hx54eVzmX6duwogfliqJ/nZ BvpWwd48Cbr+iM/fPQtXqZylsl4WNtB22wbrean8EUqYeYCKNBT+TNKAlWk6QkIZH3F5bxygo4Fa PrdjEtDnCPWqIqH5BfeI3UG0nMRk7dr/Eo8i0jmKN0TEHdTsfn1sDNBpa4AmIXzmV7IR1WYQ8Djk h4CAdaGQz1/cg7dnq20gKQm7O2MopDqI9d/dg04tfCur5vRc9QJ3TfTP9Ep7db37xkAVPIhy/aoN V+YmZfff2pKjVErODtKRBL++HZ2+Wu7jWv2oyhnj7Gua9bZjI/ar7djMzI8EbkmSIjqWGYURwg8B p1zs7oAd27mqVrmf/3tykiQQK5KQLLWLK5kfJ5gLSsI9pMFrrZ66WaXI3yFq7D3j1RX1B9ZhCgn0 pN6cr6nV7kx70/7UcaJeG3VQda1fMT3InAIuYP+FVqdF5L3W+sew/xcQ1MXoGw8AAA==#> #endregion <# .NOTES .DESCRIPTION GUI script generated by PowerShell Studio 2016 #> #---------------------------------------------- #region Application Functions #---------------------------------------------- #endregion Application Functions #---------------------------------------------- # Generated Form Function #---------------------------------------------- function Show-test-tools_psf { #---------------------------------------------- #region Import the Assemblies #---------------------------------------------- [void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') [void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') [void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') #endregion Import Assemblies #---------------------------------------------- #region Generated Form Objects #---------------------------------------------- [System.Windows.Forms.Application]::EnableVisualStyles() $form1 = New-Object 'System.Windows.Forms.Form' $panel1 = New-Object 'System.Windows.Forms.Panel' $Progressbar = New-Object 'System.Windows.Forms.ProgressBar' $Services = New-Object 'System.Windows.Forms.Label' $Output = New-Object 'System.Windows.Forms.TextBox' $ServerName = New-Object 'System.Windows.Forms.TextBox' $combobox1 = New-Object 'System.Windows.Forms.ComboBox' $ButtonConnectServer = New-Object 'System.Windows.Forms.Button' $ButtonDisplayServices = New-Object 'System.Windows.Forms.Button' $ButtonServiceStatus = New-Object 'System.Windows.Forms.Button' $ButtonServiceStart = New-Object 'System.Windows.Forms.Button' $ButtonServiceStop = New-Object 'System.Windows.Forms.Button' $ButtonServiceRestart = New-Object 'System.Windows.Forms.Button' $ButtonServiceAutomatic = New-Object 'System.Windows.Forms.Button' $ButtonServiceDisabled = New-Object 'System.Windows.Forms.Button' $ButtonServiceManual = New-Object 'System.Windows.Forms.Button' $labelServerOS = New-Object 'System.Windows.Forms.Label' $labelDisplayOS = New-Object 'System.Windows.Forms.Label' $labelServerIP = New-Object 'System.Windows.Forms.Label' $labelDisplayIP = New-Object 'System.Windows.Forms.Label' $labelServerDomain = New-Object 'System.Windows.Forms.Label' $labelDisplayDomain = New-Object 'System.Windows.Forms.Label' $labelServerType = New-Object 'System.Windows.Forms.Label' $labelDisplayServerInfo = New-Object 'System.Windows.Forms.Label' $labelFilterService = New-Object 'System.Windows.Forms.Label' $ComboboxServiceStartMode = New-Object 'System.Windows.Forms.ComboBox' $ComboboxServiceState = New-Object 'System.Windows.Forms.ComboBox' $labelProcProcesses = New-Object 'System.Windows.Forms.Label' $ButtonProcDisplay = New-Object 'System.Windows.Forms.Button' $ButtonProcStatus = New-Object 'System.Windows.Forms.Button' $ButtonKillProcess = New-Object 'System.Windows.Forms.Button' $ComboboxProc = New-Object 'System.Windows.Forms.ComboBox' $ComboboxProcSort = New-Object 'System.Windows.Forms.ComboBox' $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' $Global:ServerName = "" $Global:ServiceStatus = "" $Global:Serv = "" $Global:Proc = "" $Global:ProcessStatus = "" $Global:StartMode = "" #NA-ClearGlobalVariables #$Output.text = $Global:proc | ft -AutoSize | Out-String #$combobox1.Text = $env:COMPUTERNAME | Out-String #endregion Generated Form Objects #---------------------------------------------- # User Generated Script #---------------------------------------------- $Progressbar_Click={} $combobox1_SelectedIndexChanged={ #TODO: Place custom script here } $ComboboxServiceStartMode_SelectedIndexChanged={ NA-Load-Service $Global:StartMode = $Global:Serv | select DisplayName,Name,ProcessID,StartMode,State,Status | ? { $_.StartMode -eq $ComboboxServiceStartMode.text } NA-Populate-DropDowns -DropDownName ServiceState $Output.Text = $Global:Serv | select DisplayName,Name,ProcessID,StartMode,State,Status | ? { $_.StartMode -eq $ComboboxServiceStartMode.text } |ft -AutoSize | Out-String } $ComboboxServiceState_SelectedIndexChanged={ $Output.Text = $Global:StartMode | ? {$_.state -eq $ComboboxServiceState.Text } | ft -AutoSize | Out-String #$Output.Text = $ComboboxServiceState.Text } ################################################################################################################################################################################### $ButtonConnectServer_Click={ $combobox1.Items.Clear() $combobox1.Refresh() $ComboboxProc.Items.Clear() $ComboboxServiceStartMode.Items.Clear() # $Progressbar.Visible = $True If ($ServerName.Text -ne "-*-" -or $ServerName.Text -ne "") { $Global:ServerName = $ServerName.Text $CheckConn = NA-TestConnection -Computer $ServerName.Text If ($CheckConn -eq '1') { NA-Populate-DropDowns -DropDownName Service NA-Populate-DropDowns -DropDownName Process NA-Populate-DropDowns -DropDownName Sort NA-Populate-DropDowns -DropDownName FilterStartMode #NA-Load-Service #NA-Load-Process NA-ServerInfo } Else { $Global:ServerName = "" NA-Messages -MessageType ServerNotFound #$Output.Text = "Server NOT Found. Please Check Server Name ...... !" | Out-String } }#end If Else { NA-Messages -MessageType ServerNotFound } $Progressbar.Visible = $False } ################################################################################################################################################################################### $ButtonDisplayServices_Click={ If ($Global:ServerName) { NA-Load-Service #$Output.Text = $Global:Serv | select PsComputerName,Name,ProcessID,StartMode,State,Status | ft -AutoSize| Out-String } Else { NA-Messages -MessageType ConnectServer } } $ButtonServiceStatus_Click={ If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { NA-Service-Status #$Output.Text = $Global:ServiceStatus | ft -AutoSize | Out-String } Else { NA-Messages -MessageType ServiceStatus } } $ButtonServiceStart_Click={ If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { NA-StartService } Else { NA-Messages -MessageType ServiceStatus } } $ButtonServiceStop_Click={ If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { NA-Service-Status NA-Service-State -State Stopped } Else { NA-Messages -MessageType ServiceStatus } } $ButtonServiceRestart_Click={ NA-Service-Status If ($Global:ServiceStatus.state -eq "Running") { $Output.Text = "Re-Starting Service: $($combobox1.Text) ...... Please Wait! " Restart-Service $combobox1.Text Start-Sleep -Seconds 3 $Output.Text = Gwmi Win32_Service -ComputerName $Global:ServerName | ? {$_.DisplayName -eq $combobox1.Text} | select name,displayname,state,startmode | ft -AutoSize | Out-String } Elseif ($Global:ServiceStatus.startmode -eq "Disabled") { $Output.Text = "The Service: $($Global:ServiceStatus.name) is currently Disabled.....!!" } Elseif ($Global:ServiceStatus.state -eq "Stopped") { $Output.Text = "The Service: $($Global:ServiceStatus.name) is currently NOT Running.....!!" } Else { NA-Messages -MessageType ServiceStatus} } $ButtonServiceAutomatic_Click={ If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { NA-Service-State -State Automatic } Else { NA-Messages -MessageType ServiceStatus } } $ButtonServiceDisabled_Click={ If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { NA-Service-State -State Disabled } Else { NA-Messages -MessageType ServiceStatus } } $ButtonServiceManual_Click={ If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { NA-Service-State -State Manual } Else { NA-Messages -MessageType ServiceStatus } } $labelServerOS_Click={} $labelDisplayOS_Click={} $labelServerIP_Click={} $labelDisplayIP_Click={} $labelServerDomain_Click={} $labelDisplayDomain_Click={} $labelServerType_Click={} $labelDisplayServerInfo_Click={} $labelFilterService_Click={} $form1_Load={ #TODO: Place custom script here } $ServerName1_Click={ #TODO: Place custom script here } $Server_Click={ #TODO: Place custom script here } $Output_TextChanged={ #TODO: Place custom script here } ######################################################################################################################################### $labelProcProcesses_Click={} $ButtonProcDisplay_Click={ If ($Global:ServerName) { NA-Load-Process #$Output.Text = $Global:Proc | ft -AutoSize | Out-String } Else { NA-Messages -MessageType ConnectServer } } $ButtonProcStatus_Click={ NA-Process-Status <#; $Output.Text = $Global:ProcessStatus | ft -AutoSize | Out-String #>} $ButtonKillProcess_Click={ If ($ComboboxProc.Text -ne "" -and $ComboboxProc.Text -notlike "--*" -and ($Global:ServerName)) { NA-KillProcess -ProcessSelected ($ComboboxProc.text)} Else { NA-Messages -MessageType ProcessStatus } } $ComboboxProc_SelectedIndexChanged={} $ComboboxProcSort_SelectedIndexChanged={ $Output.text = $Global:Proc | sort $ComboboxProcSort.text | ft -AutoSize | Out-String} ######################################################################################################################################### function NA-ServerInfo { $OS = Gwmi win32_Operatingsystem -ComputerName $Global:ServerName | select -ExpandProperty caption $labelDisplayOS.Text = $OS | Out-String $IP = Test-Connection -ComputerName $Global:ServerName -Count 1 -ErrorAction SilentlyContinue | select -ExpandProperty IPV4Address $labelDisplayIP.text = $IP.IPAddressToString | Out-String $GetMachineInfo = Gwmi win32_Computersystem -ComputerName $Global:ServerName | Select model,domain $Domain = ($GetMachineInfo.domain).toupper() $labelDisplayDomain.Text = $Domain | Out-String Switch -Wildcard ($GetMachineInfo.model) { "Vmware*" { $labelDisplayServerInfo.Text = "VMWare VM"} "Virtual*" { $labelDisplayServerInfo.Text = "Hyper-V VM"} Default { $labelDisplayServerInfo.Text = "Physical Server"} } } ######################################################################################################################################### function NA-Load-Service { #Param ($Computer) #$combobox1.Items.Clear() #$Global:Serv = "" #$Global:Serv = Get-Service -ComputerName $Global:ServerName | sort displayname # | select -ExpandProperty displayname #$Global:Serv = Gwmi Win32_Service -ComputerName $Global:ServerName | sort displayname $Output.Text = $Global:Serv | select PsComputerName,Name,ProcessID,StartMode,State,Status | ft -AutoSize| Out-String #$Global:Serv | % { $combobox1.Items.Add($_.displayname) } } ######################################################################################################################################### function NA-Service-Status { If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { $Global:ServiceStatus = Gwmi Win32_Service -ComputerName $Global:ServerName | ? {$_.DisplayName -eq $combobox1.Text} $Output.Text = $Global:ServiceStatus | select PsComputerName,Name,ProcessID,StartMode,State,Status | ft -AutoSize | Out-String } Else { NA-Messages -MessageType ServiceStatus #$Output.Text = "Please Select a Service or Connect to a Server ... !" } } ######################################################################################################################################### function NA-Service-State { Param($State) #$SelectedService = Get-Service -ComputerName $Global:ServerName -DisplayName $combobox1.Text | select -ExpandProperty name #$Global:ServiceStatus Switch($State) { Automatic { $Global:ServiceStatus.changestartmode("Automatic") } Manual { $Global:ServiceStatus.changestartmode("Manual") } Disabled { $Global:ServiceStatus.stopservice();$Global:ServiceStatus.changestartmode("Disabled") } Stopped { $Global:ServiceStatus.stopservice() } } NA-Service-Status $Output.Text = $Global:ServiceStatus | select name,displayname,state,startmode | ft -AutoSize | Out-String } ######################################################################################################################################### ######################################################################################################################################### function NA-Load-Process { <# $ComboboxProc.Items.Clear() $Global:Proc = Invoke-Command -ComputerName $Global:ServerName { Get-Process } #$temp = $Global:Proc | select processname,id $i = 0 $Q = @() foreach ($P in $Global:Proc) { $Q += $Global:Proc[$i].ProcessName + " -- ID = " + "$($Global:Proc[$i].ID)" #$Q += $P[$i].ProcessName # $Q[$i] $ComboboxProc.Items.Add($Q[$i]) $i++ } #> $Output.Text = $Global:Proc | ft -AutoSize | Out-String #$Output.Text = $Q | Out-String } ######################################################################################################################################### function NA-Process-Status { If ($ComboboxProc.Text -ne "" -and $ComboboxProc.Text -notlike "--*" -and ($Global:ServerName)) { NA-GlobalProcess $Output.Text = $Global:ProcessStatus | ft -AutoSize | Out-String # $Output.Text = "You select $($ComboboxProc.text)" } Else { NA-Messages -MessageType ProcessStatus #$Output.Text = "Please Select a Process or Connect to a Server ... !" } } ######################################################################################################################################### function NA-KillProcess { Param($ProcessSelected) $output.Text = "Killing Process: $ProcessSelected --- Please Wait..." $ProcessSelectedID = ($ProcessSelected.split("="))[-1] $TerminateProcess = Gwmi Win32_Process -ComputerName $Global:ServerName -Filter "ProcessID=$ProcessSelectedID" $TerminateProcess.terminate() | Out-Null Start-Sleep -Seconds 3 $output.Text = "Done ! -- Re-Loading Process List..." Start-Sleep -Seconds 3 NA-Load-Process $Output.Text = $Global:Proc | ft -AutoSize | Out-String } ######################################################################################################################################### function NA-GlobalProcess { #$Proc = $ComboboxProc.text $Proc = ($ComboboxProc.text.split("="))[-1] #$output.Text = $Proc $Global:ProcessStatus = Invoke-Command -ComputerName $Global:ServerName { Param($Proc) Gwmi Win32_Process | ? { $_.ProcessID -eq $Proc} } -ArgumentList $Proc } ######################################################################################################################################### ######################################################################################################################################### function NA-TestConnection { param ($Computer) If (!$Computer) {$Output.Text = "Please Enter Server Name in the Box!!" | Out-String} Else { $TConn = Test-Connection -ComputerName $Computer -Count 1 -ErrorAction SilentlyContinue } If ($TConn) { $Output.Text = "Getting information from server: $Computer " Write-Output '1' } Else { Write-Output '0' } } ######################################################################################################################################### function NA-StartService { # $SvcStatus = Gwmi Win32_Service -ComputerName $Global:ServerName | ? {$_.DisplayName -eq $combobox1.Text} | select name,displayname,state,startmode NA-Service-Status #$Output.Text = "Starting Service: $($Global:ServiceStatus.displayname) on $Global:ServerName" | Out-String $Output.Text = "Global Server Name: $($Global:Servername) ---- Global Service Status: $($Global:ServiceStatus.displayname)" | Out-String #$ServiceStatus = Get-Service -Name $ServiceName -ComputerName $Global:ServerName #$ServiceSelected = $combobox1.text #NA-GlobalService Switch($Global:ServiceStatus.startmode) { #Switch($ServiceStatus.startmode) { #Restart { $Output.Text = "Re-starting Service: $($Global:ServiceStatus.displayname) ..... please wait"; Restart-Service -DisplayName $Global:ServiceStatus.displayname } #Manual { Start-Service -DisplayName $Global:ServiceStatus.displayname } Disabled { $Output.Text = "Starting Service ..... please wait"; NA-Service-State -State Manual; $Global:ServiceStatus.StartService() <# Get-Service -Name $Global:ServiceStatus.name -ComputerName $Global:ServerName | Start-Service #>} Default { $Global:ServiceStatus.StartService() } #Disabled { $Output.Text = "Disabled" } #Default { $Output.Text = "Manual"} } #$CurrentService = Get-Service -DisplayName $ServiceSelected #Get-Service -DisplayName $($combobox1.text) -ComputerName $Global:ServerName | Start-Service | Out-String Start-Sleep -Seconds 4 #$Output.Text = Get-Service -DisplayName $ServiceSelected | ft -AutoSize | Out-String NA-Service-Status $Output.Text = $Global:ServiceStatus | select name,displayname,state,startmode | ft -AutoSize | Out-String } ######################################################################################################################################### function NA-ClearGlobalVariables { $Global:ServerName = "" $Global:ServiceStatus = "" $Global:Serv = "" $Global:Proc = "" $Global:ProcessStatus ="" } ######################################################################################################################################### Function NA-Populate-DropDowns { Param($DropDownName) Switch($DropDownName) { Service { $Global:Serv = Gwmi Win32_Service -ComputerName $Global:ServerName | sort displayname $Global:Serv | % { $combobox1.Items.Add($_.displayname) } }#endService Process { $ComboboxProc.Items.Clear() $Global:Proc = Invoke-Command -ComputerName $Global:ServerName { Get-Process } $i = 0 $Q = @() foreach ($P in $Global:Proc) { $Q += $Global:Proc[$i].ProcessName + " -- ID = " + "$($Global:Proc[$i].ID)" #$Q += $P[$i].ProcessName # $Q[$i] $ComboboxProc.Items.Add($Q[$i]) $i++ }#endForeach }#endProcess Sort { $Items = "CPU","VM","ProcessName" $ComboboxProcSort.items.Clear() $Items | % { $ComboboxProcSort.Items.Add($_) } } FilterStartMode { $Items = "Auto","Manual","Disabled" $ComboboxServiceStartMode.items.Clear() $Items | % { $ComboboxServiceStartMode.Items.Add($_) }} ServiceState { $ComboboxServiceStateItems = "Stopped","Running" $ComboboxServiceState.items.Clear() $ComboboxServiceStateItems | % { $ComboboxServiceState.Items.Add($_) }} }#endSwitch }#endFunction ######################################################################################################################################### function xNA-GlobalService { #$Global:ServiceStatus = "" If ($combobox1.Text -ne "" -and $combobox1.Text -notlike "--*" -and ($Global:ServerName)) { $Global:ServiceStatus = Gwmi Win32_Service -ComputerName $Global:ServerName | ? {$_.DisplayName -eq $combobox1.Text} | select displayname,name,state,startmode #$Global:ServiceStatus = Get-Service -ComputerName $Global:ServerName -DisplayName $combobox1.Text } Else { $Output.Text = "Please Connect to a Server or Select a Service from the Drop down ... !"} } ######################################################################################################################################### function NA-Messages { Param($MessageType) Switch($MessageType) { ConnectServer { $Output.Text = "Server NOT Found. Please Check Server Name and Connect ...... !!" } ServerNotFound { $Output.Text = "Cannot Connect to Server. Please Check Server Name and Connect ......!!"} ServiceStatus { $Output.Text = "Please Select a Service or Connect to a Server ... !!" } ProcessStatus { $Output.Text = "Please Select a Process or Connect to a Server ... !!" } }#end Switch } ######################################################################################################################################### # --End User Generated Script-- #---------------------------------------------- #region Generated Events #---------------------------------------------- $Form_StateCorrection_Load= { #Correct the initial state of the form to prevent the .Net maximized form issue $form1.WindowState = $InitialFormWindowState } $Form_Cleanup_FormClosed= { #Remove all event handlers from the controls try { $Progressbar.remove_Click($Progressbar_Click) $Services.remove_Click($Services_Click) $Output.remove_TextChanged($Output_TextChanged) $combobox1.remove_SelectedIndexChanged($combobox1_SelectedIndexChanged) $ComboboxServiceStartMode.remove_SelectedIndexChanged($ComboboxServiceStartMode_SelectedIndexChanged) $ComboboxServiceState.remove_SelectedIndexChanged($ComboboxServiceState_SelectedIndexChanged) $ButtonDisplayServices.remove_Click($ButtonDisplayServices_Click) $ButtonServiceStatus.remove_Click($ButtonServiceStatus_Click) $ButtonConnectServer.remove_Click($ButtonConnectServer_Click) $ButtonServiceStart.remove_Click($ButtonServiceStart_Click) $ButtonServiceStop.remove_Click($ButtonServiceStop_Click) $ButtonServiceRestart.remove_Click($ButtonServiceRestart_Click) $ButtonServiceAutomatic.remove_Click($ButtonServiceAutomatic_Click) $ButtonServiceDisabled.remove_Click($ButtonService_Click) $ButtonServiceManual.remove_Click($ButtonServiceManual_Click) $labelServerOS.remove_Click($labelServerOS_Click) $labelDisplayOS.remove_Click($labelDisplayOS_Click) $labelServerIP.remove_Click($labelServer_Click) $labelDisplayIP.remove_Click($labelDisplayIP_Click) $labelServerDomain.remove_Click($labelServer_Click) $labelDisplayDomain.remove_Click($labelDisplayDomain_Click) $labelServerType.remove_Click($labelServer_Click) $labelDisplayServerInfo.remove_Click($labelDisplayServerInfo_Click) $labelFilterService.remove_Click($labelFilterService_Click) $labelProcProcesses.remove_Click($labelProcProcesses_Click) $ButtonProcDisplay.remove_Click($ButtonProcDisplay_Click) $ButtonProcStatus.remove_Click($ButtonProcStatus_Click) $ButtonKillProcess.remove_Click($ButtonKillProcess_Click) $ComboboxProc.remove.SelectedIndexChanged($ComboboxProc_SelectedIndexChanged) $ComboboxProcSort.remove.SelectedIndexChanged($ComboboxProcSort_SelectedIndexChanged) $form1.remove_Load($form1_Load) $form1.remove_Load($Form_StateCorrection_Load) $form1.remove_FormClosed($Form_Cleanup_FormClosed) NA-ClearGlobalVariables } catch { Out-Null <# Prevent PSScriptAnalyzer warning #> } } #endregion Generated Events #---------------------------------------------- #region Generated Form Code #---------------------------------------------- $form1.SuspendLayout() $panel1.SuspendLayout() # # form1 # $form1.Controls.Add($Progressbar) $form1.Controls.Add($Services) $form1.Controls.Add($panel1) $form1.Controls.Add($Output) $form1.Controls.Add($ServerName) $form1.Controls.Add($combobox1) $form1.Controls.Add($ComboboxServiceStartMode) $form1.Controls.Add($ComboboxServiceState) $form1.Controls.Add($ButtonDisplayServices) $form1.Controls.Add($ButtonServiceStatus) $form1.Controls.Add($ButtonConnectServer) $form1.Controls.Add($ButtonServiceStart) $form1.Controls.Add($ButtonServiceStop) $form1.Controls.Add($ButtonServiceRestart) $form1.Controls.Add($ButtonServiceAutomatic) $form1.Controls.Add($ButtonServiceDisabled) $form1.Controls.Add($ButtonServiceManual) $form1.Controls.Add($labelServerOS) $form1.Controls.Add($labelDisplayOS) $form1.Controls.Add($labelServerIP) $form1.Controls.Add($labelDisplayIP) $form1.Controls.Add($labelServerDomain) $form1.Controls.Add($labelDisplayDomain) $form1.Controls.Add($labelServerType) $form1.Controls.Add($labelDisplayServerInfo) $form1.Controls.Add($labelFilterService) $form1.Controls.Add($labelProcProcesses) $form1.Controls.Add($ButtonProcDisplay) $form1.controls.Add($ButtonProcStatus) $form1.Controls.Add($ButtonKillProcess) $form1.Controls.Add($ComboboxProc) $form1.Controls.Add($ComboboxProcSort) $form1.AutoScaleDimensions = '6, 13' $form1.AutoScaleMode = 'Font' $form1.ClientSize = '990, 660' $form1.Name = 'form1' $form1.Text = 'Form' $form1.add_Load($form1_Load) # # panel1 # $panel1.Controls.Add($ServerName) $panel1.Controls.Add($labelServerOS) $panel1.Controls.Add($labelDisplayOS) $panel1.Controls.Add($labelServerIP) $panel1.Controls.Add($labelDisplayIP) $panel1.Controls.Add($labelServerDomain) $panel1.Controls.Add($labelDisplayDomain) $panel1.Controls.Add($labelServerType) $panel1.controls.Add($labelDisplayServerInfo) $panel1.Controls.Add($ButtonConnectServer) $panel1.BackColor = 'ActiveCaption' $panel1.ForeColor = 'ControlText' $panel1.Location = '12, 12' $panel1.Name = 'panel1' $panel1.Size = '965, 34' $panel1.TabIndex = 7 # # # Progressbar # $Progressbar.Location = '60, 111' $Progressbar.Maximum = $Global:Serv.count $Progressbar.Step = 1 $Progressbar.Value = 0 $Progressbar.Style="Continuous" $Progressbar.Name = 'Progressbar' $Progressbar.Size = '600, 23' $Progressbar.TabIndex = 9 $Progressbar.add_Click($Progressbar_Click) $Progressbar.Visible = $False # # Services # $Services.AutoSize = $True $Services.Location = '12, 60' $Services.Name = 'Services' $Services.Size = '41, 13' $Services.TabIndex = 6 $Services.Text = 'Service:' $Services.add_Click($Services_Click) # # labelFilterService # $labelFilterService.AutoSize = $True $labelFilterService.Location = '88, 90' $labelFilterService.Name = 'Filter' $labelFilterService.Size = '41, 13' $labelFilterService.TabIndex = 6 $labelFilterService.Text = 'Filter:' $labelFilterService.add_Click($labelFilterService_Click) # # labelProcProcesses # $labelProcProcesses.AutoSize = $True $labelProcProcesses.Location = '12, 120' $labelProcProcesses.Name = 'Proceses' $labelProcProcesses.Size = '41, 13' $labelProcProcesses.Text = 'Processes:' $labelProcProcesses.add_Click($labelProcProcesses_Click) # # labelServerOS # $labelServerOS.AutoSize = $True $labelServerOS.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' $labelServerOS.ForeColor = 'DarkGreen' $labelServerOS.TextAlign = 'MiddleRight' $labelServerOS.Location = '264, 3' $labelServerOS.Name = 'OS' $labelServerOS.Size = '41, 13' $labelServerOS.TabIndex = 6 $labelServerOS.Text = 'O/S:' $labelServerOS.add_Click($labelServerOS_Click) # # labelDisplayOS # $labelDisplayOS.AutoSize = $True $labelDisplayOS.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' $labelDisplayOS.ForeColor = 'DarkGreen' $labelDisplayOS.TextAlign = 'MiddleRight' $labelDisplayOS.Location = '295, 3' $labelDisplayOS.Name = 'DisplayOS' $labelDisplayOS.Size = '41, 13' $labelDisplayOS.TabIndex = 7 $labelDisplayOS.Text = '-----' $labelDisplayOS.add_Click($labelDisplayOS_Click) # # labelServerIP # $labelServerIP.AutoSize = $True $labelServerIP.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' $labelServerIP.TextAlign = 'MiddleRight' $labelServerIP.Location = '272, 17' $labelServerIP.Name = 'IP' $labelServerIP.Size = '41, 13' $labelServerIP.TabIndex = 6 $labelServerIP.Text = 'IP:' $labelServerIP.add_Click($labelServerIP_Click) # # labelDisplayIP # $labelDisplayIP.AutoSize = $True $labelDisplayIP.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' $labelDisplayIP.TextAlign = 'MiddleRight' $labelDisplayIP.Location = '295, 17' $labelDisplayIP.Name = 'DisplayIP' $labelDisplayIP.Size = '41, 13' $labelDisplayIP.TabIndex = 8 $labelDisplayIP.Text = '-----' $labelDisplayIP.add_Click($labelDisplayIP_Click) # # labelServerDomain # $labelServerDomain.AutoSize = $True $labelServerDomain.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' $labelServerDomain.Location = '530, 3' $labelServerDomain.Name = 'Domain' $labelServerDomain.Size = '41, 13' $labelServerDomain.TabIndex = 10 $labelServerDomain.Text = 'Domain:' $labelServerDomain.add_Click($labelServerDomain_Click) # # labelDisplayDomain $labelDisplayDomain.AutoSize = $True $labelDisplayDomain.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' $labelDisplayDomain.Location = '580, 3' $labelDisplayDomain.Name = 'DisplayDomain' $labelDisplayDomain.Size = '41, 13' $labelDisplayDomain.TabIndex = 9 $labelDisplayDomain.Text = '-----' $labelDisplayDomain.add_Click($labelDisplayDomain_Click) # # labelServerType # $labelServerType.AutoSize = $True $labelServerType.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' $labelServerType.Location = '542, 17' $labelServerType.Name = 'Type' $labelServerType.Size = '41, 13' $labelServerType.TabIndex = 6 $labelServerType.Text = 'Type:' $labelServerType.add_Click($labelServerType_Click) # # labelDisplayServerInfo # $labelDisplayServerInfo.AutoSize = $True $labelDisplayServerInfo.Font = 'Microsoft Sans Serif, 7.50pt, style=Bold' $labelDisplayServerInfo.Location = '580, 17' $labelDisplayServerInfo.Name = 'ServerType' $labelDisplayServerInfo.Size = '41, 13' $labelDisplayServerInfo.TabIndex = 11 $labelDisplayServerInfo.Text = '-----' $labelDisplayServerInfo.add_Click($labelDisplayServerInfo_Click) # # Output # $Output.Location = '12, 280' $Output.Multiline = $True $Output.Name = 'Output' $Output.ScrollBars = 'both' $Output.Size = '790, 360' $Output.Font = 'Consolas, 8.25pt' $Output.WordWrap = $False $Output.TabIndex = 5 $Output.add_TextChanged($Output_TextChanged) # # ServerName # $ServerName.BackColor = '255, 255, 192' $ServerName.Font = 'Microsoft Sans Serif, 12pt, style=Bold' $ServerName.Location = '4, 4' $ServerName.Text = "--ServerName--" $ServerName.Name = 'ServerName' $ServerName.BackColor = '255, 255, 192' $ServerName.TextAlign = 'Center' $ServerName.Size = '130, 20' $ServerName.TabIndex = 3 # # combobox1 # $combobox1.FormattingEnabled = $True $combobox1.Location = '286, 55' $combobox1.Name = 'combobox1' $combobox1.Size = '165, 21' $combobox1.TabIndex = 2 $combobox1.Text = '---Select Service---' $combobox1.add_SelectedIndexChanged($combobox1_SelectedIndexChanged) # # ComboboxServiceStartMode # $ComboboxServiceStartMode.FormattingEnabled = $True $ComboboxServiceStartMode.Location = '125, 86' $ComboboxServiceStartMode.Name = 'ComboboxServiceStartMode' $ComboboxServiceStartMode.Size = '90, 21' $ComboboxServiceStartMode.TabIndex = 2 $ComboboxServiceStartMode.Text = '--Start Mode--' $ComboboxServiceStartMode.add_SelectedIndexChanged($ComboboxServiceStartMode_SelectedIndexChanged) # # ComboboxServiceState # $ComboboxServiceState.FormattingEnabled = $True $ComboboxServiceState.Location = '225, 86' $ComboboxServiceState.Name = 'ComboboxServiceState' $ComboboxServiceState.Size = '90, 21' $ComboboxServiceState.TabIndex = 2 $ComboboxServiceState.Text = '--State--' $ComboboxServiceState.add_SelectedIndexChanged($ComboboxServiceState_SelectedIndexChanged) # # ComboboxProc # $ComboboxProc.FormattingEnabled = $True $ComboboxProc.Location = '286, 115' $ComboboxProc.Name = 'ComboboxProc' $ComboboxProc.Size = '165, 21' $ComboboxProc.TabIndex = 2 $ComboboxProc.Text = '---Select Process---' $ComboboxProc.add_SelectedIndexChanged($ComboboxProc_SelectedIndexChanged) # # ComboboxProcSort # $ComboboxProcSort.FormattingEnabled = $True $ComboboxProcSort.Location = '547, 115' $ComboboxProcSort.Name = 'SortBy' $ComboboxProcSort.Size = '90, 21' $ComboboxProcSort.TabIndex = 2 $ComboboxProcSort.Text = '---Sort By---' $ComboboxProcSort.add_SelectedIndexChanged($ComboboxProcSort_SelectedIndexChanged) # # ButtonDisplayServices # $ButtonDisplayServices.Location = '88, 54' $ButtonDisplayServices.Name = 'DisplayService' $ButtonDisplayServices.Size = '100, 23' $ButtonDisplayServices.TabIndex = 1 $ButtonDisplayServices.Text = 'Display Services' $ButtonDisplayServices.UseVisualStyleBackColor = $True $ButtonDisplayServices.add_Click($ButtonDisplayServices_Click) # # ButtonProcDisplay # $ButtonProcDisplay.Location = '88, 114' $ButtonProcDisplay.Name = 'DisplayProcess' $ButtonProcDisplay.Size = '105, 23' $ButtonProcDisplay.TabIndex = 1 $ButtonProcDisplay.Text = 'Display Processes' $ButtonProcDisplay.UseVisualStyleBackColor = $True $ButtonProcDisplay.add_Click($ButtonProcDisplay_Click) # # Service # $ButtonServiceStatus.Location = '199, 54' $ButtonServiceStatus.Name = 'ServiceStatus' $ButtonServiceStatus.Size = '80, 23' $ButtonServiceStatus.TabIndex = 1 $ButtonServiceStatus.Text = 'Status' $ButtonServiceStatus.UseVisualStyleBackColor = $True $ButtonServiceStatus.add_Click($ButtonServiceStatus_Click) # # ButtonProcStatus $ButtonProcStatus.Location = '199, 114' $ButtonProcStatus.Name = 'ProcessStatus' $ButtonProcStatus.Size = '80, 23' $ButtonProcStatus.TabIndex = 1 $ButtonProcStatus.Text = 'Status' $ButtonProcStatus.UseVisualStyleBackColor = $True $ButtonProcStatus.add_Click($ButtonProcStatus_Click) # # ButtonKillProcess # $ButtonKillProcess.Location = '460, 115' $ButtonKillProcess.Name = 'KillProcess' $ButtonKillProcess.Size = '80, 23' $ButtonKillProcess.TabIndex = 1 $ButtonKillProcess.Text = 'Kill Process' $ButtonKillProcess.UseVisualStyleBackColor = $True $ButtonKillProcess.add_Click($ButtonKillProcess_Click) # # ButtonConnectServer # $ButtonConnectServer.Location = '156, 6' $ButtonConnectServer.Name = 'ConnectServer' $ButtonConnectServer.Text = 'Connect' $ButtonConnectServer.UseVisualStyleBackColor = $True $ButtonConnectServer.add_Click($ButtonConnectServer_Click) # # $form1.ResumeLayout() $panel1.ResumeLayout() # # ButtonServiceStart # $ButtonServiceStart.Location = '458, 54' $ButtonServiceStart.Name = 'StartService' $ButtonServiceStart.Size = '65, 23' $ButtonServiceStart.TabIndex=2 $ButtonServiceStart.Text = 'Start' $ButtonServiceStart.UseVisualStyleBackColor = $True $ButtonServiceStart.add_Click($ButtonServiceStart_Click) $ButtonServiceStart.ResumeLayout() # # $ButtonServiceStop # $ButtonServiceStop.Location = '530, 54' $ButtonServiceStop.Name = 'StopService' $ButtonServiceStop.Size = '65, 23' $ButtonServiceStop.TabIndex = 3 $ButtonServiceStop.Text = 'Stop' $ButtonServiceStop.UseVisualStyleBackColor = $True $ButtonServiceStop.add_Click($ButtonServiceStop_Click) $ButtonServiceStop.ResumeLayout() # # ButtonServiceRestart # $ButtonServiceRestart.Location = '602, 54' $ButtonServiceRestart.Name = 'RestartService' $ButtonServiceRestart.Size = '65, 23' $ButtonServiceRestart.TabIndex = 3 $ButtonServiceRestart.Text = 'Restart' $ButtonServiceRestart.UseVisualStyleBackColor = $True $ButtonServiceRestart.add_Click($ButtonServiceRestart_Click) $ButtonServiceRestart.ResumeLayout() # # ButtonServiceAutomatic # $ButtonServiceAutomatic.Location = '674, 54' $ButtonServiceAutomatic.Name = 'AutomaticService' $ButtonServiceAutomatic.Size = '65, 23' $ButtonServiceAutomatic.TabIndex = 3 $ButtonServiceAutomatic.Text = 'Automatic' $ButtonServiceAutomatic.UseVisualStyleBackColor = $True $ButtonServiceAutomatic.add_Click($ButtonServiceAutomatic_Click) $ButtonServiceAutomatic.ResumeLayout() # # ButtonServiceDisabled # $ButtonServiceDisabled.Location = '818, 54' $ButtonServiceDisabled.Name = 'DisabledService' $ButtonServiceDisabled.Size = '65, 23' $ButtonServiceDisabled.TabIndex = 3 $ButtonServiceDisabled.Text = 'Disabled' $ButtonServiceDisabled.UseVisualStyleBackColor = $True $ButtonServiceDisabled.add_Click($ButtonServiceDisabled_Click) $ButtonServiceDisabled.ResumeLayout() # # # $ButtonServiceManual.Location = '746, 54' $ButtonServiceManual.Name = 'ManualService' $ButtonServiceManual.Size = '65, 23' $ButtonServiceManual.TabIndex = 3 $ButtonServiceManual.Text = 'Manual' $ButtonServiceManual.UseVisualStyleBackColor = $True $ButtonServiceManual.add_Click($ButtonServiceManual_Click) $ButtonServiceManual.ResumeLayout() # #endregion Generated Form Code #---------------------------------------------- #Save the initial state of the form $InitialFormWindowState = $form1.WindowState #Init the OnLoad event to correct the initial state of the form $form1.add_Load($Form_StateCorrection_Load) #Clean up the control events $form1.add_FormClosed($Form_Cleanup_FormClosed) #Show the Form return $form1.ShowDialog() } #End Function #Call the form Show-test-tools_psf | Out-Null