#------------------------------------------------------------------------ # Source File Information (DO NOT MODIFY) # Source ID: 91a1f445-e055-46d8-87c3-f31bd1db22a7 # Source File: ComputerPrompt.psf #------------------------------------------------------------------------ <# .NOTES -------------------------------------------------------------------------------- Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2014 v4.1.62 Generated on: 6/18/2014 3:45 PM Generated by: David Organization: SAPIEN Technologies, Inc. -------------------------------------------------------------------------------- .DESCRIPTION GUI script generated by PowerShell Studio 2014 #> #---------------------------------------------- #region Application Functions #---------------------------------------------- function OnApplicationLoad { #TODO: Add custom code to validate application load #TODO: Add Snapins here return $true #return true for success or false for failure } function OnApplicationExit { #TODO: Add custom code clean up on application exit } #endregion Application Functions #---------------------------------------------- # Generated Form Function #---------------------------------------------- function Call-ComputerPrompt_psf { #---------------------------------------------- #region Import the Assemblies #---------------------------------------------- [void][reflection.assembly]::Load('mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') [void][reflection.assembly]::Load('System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') [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') [void][reflection.assembly]::Load('System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') [void][reflection.assembly]::Load('System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') [void][reflection.assembly]::Load('System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089') [void][reflection.assembly]::Load('System.ServiceProcess, 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' $textboxResults = New-Object 'System.Windows.Forms.TextBox' $chkBIOS = New-Object 'System.Windows.Forms.CheckBox' $chkCompSys = New-Object 'System.Windows.Forms.CheckBox' $chkOS = New-Object 'System.Windows.Forms.CheckBox' $txtComputerName = New-Object 'System.Windows.Forms.TextBox' $btnExit = New-Object 'System.Windows.Forms.Button' $btnUpdate = New-Object 'System.Windows.Forms.Button' $lblPrompt = New-Object 'System.Windows.Forms.Label' $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' #endregion Generated Form Objects #---------------------------------------------- # User Generated Script #---------------------------------------------- $handler_btnExit_Click={ $form1.Close() } $handler_btnUpdate_Click={ #save the current cursor $cursor = $form1.Cursor #change to wait cursor $form1.Cursor = [System.Windows.Forms.Cursors]::WaitCursor # "Gathering system information for {0}" -f $txtComputerName.Text.toUpper() $stringBuilder = New-Object System.Text.StringBuilder $text = "System Report for {0} {1}" -f $txtComputerName.Text.toUpper(),(Get-Date -Format g) $stringBuilder.AppendLine($text) $stringBuilder.AppendLine("") if ($chkOS.Checked) { $stringBuilder.AppendLine("Operating System") $stringBuilder.Append("*" * 50) $text = "" $text = (Get-WmiObject win32_operatingsystem -computername $txtComputerName.Text) |Out-String $stringBuilder.AppendLine($text) } if ($chkCompSys.Checked) { $stringBuilder.AppendLine("Computer System") $stringBuilder.Append("*" * 50) $text = "" $text = (Get-WmiObject win32_computersystem -computername $txtComputerName.Text) |Out-String $stringBuilder.AppendLine($text) } if ($chkBIOS.Checked) { $stringBuilder.AppendLine("BIOS") $stringBuilder.Append("*" * 50) $text = "" $text = (Get-WmiObject win32_BIOS -computername $txtComputerName.Text) | Out-String $stringBuilder.AppendLine($text) } #write data to the pipeline $textboxResults.Text = $stringBuilder.ToString() #restore the cursor $form1.Cursor = $cursor } # --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 { $btnExit.remove_Click($handler_btnExit_Click) $btnUpdate.remove_Click($handler_btnUpdate_Click) $form1.remove_Load($Form_StateCorrection_Load) $form1.remove_FormClosed($Form_Cleanup_FormClosed) } catch [Exception] { } } #endregion Generated Events #---------------------------------------------- #region Generated Form Code #---------------------------------------------- $form1.SuspendLayout() # # form1 # $form1.Controls.Add($textboxResults) $form1.Controls.Add($chkBIOS) $form1.Controls.Add($chkCompSys) $form1.Controls.Add($chkOS) $form1.Controls.Add($txtComputerName) $form1.Controls.Add($btnExit) $form1.Controls.Add($btnUpdate) $form1.Controls.Add($lblPrompt) $form1.ClientSize = '476, 375' $form1.Name = "form1" $form1.Text = "Computer Prompt" # # textboxResults # $textboxResults.Anchor = 'Top, Bottom, Left, Right' $textboxResults.BackColor = 'Window' $textboxResults.Location = '13, 56' $textboxResults.Multiline = $True $textboxResults.Name = "textboxResults" $textboxResults.ReadOnly = $True $textboxResults.ScrollBars = 'Both' $textboxResults.Size = '451, 278' $textboxResults.TabIndex = 7 # # chkBIOS # $chkBIOS.AutoSize = $True $chkBIOS.Location = '246, 32' $chkBIOS.Name = "chkBIOS" $chkBIOS.Size = '51, 17' $chkBIOS.TabIndex = 6 $chkBIOS.Text = "BIOS" $chkBIOS.UseVisualStyleBackColor = $True # # chkCompSys # $chkCompSys.AutoSize = $True $chkCompSys.Location = '132, 32' $chkCompSys.Name = "chkCompSys" $chkCompSys.Size = '108, 17' $chkCompSys.TabIndex = 5 $chkCompSys.Text = "Computer System" $chkCompSys.UseVisualStyleBackColor = $True # # chkOS # $chkOS.AutoSize = $True $chkOS.Checked = $True $chkOS.CheckState = 'Checked' $chkOS.Location = '13, 32' $chkOS.Name = "chkOS" $chkOS.Size = '109, 17' $chkOS.TabIndex = 4 $chkOS.Text = "Operating System" $chkOS.UseVisualStyleBackColor = $True # # txtComputerName # $txtComputerName.Location = '138, 6' $txtComputerName.Name = "txtComputerName" $txtComputerName.Size = '180, 20' $txtComputerName.TabIndex = 3 $txtComputerName.Text = "$env:computername" # # btnExit # $btnExit.Anchor = 'Bottom, Right' $btnExit.Location = '389, 340' $btnExit.Name = "btnExit" $btnExit.Size = '75, 23' $btnExit.TabIndex = 2 $btnExit.Text = "Exit" $btnExit.UseVisualStyleBackColor = $True $btnExit.add_Click($handler_btnExit_Click) # # btnUpdate # $btnUpdate.Anchor = 'Bottom, Left' $btnUpdate.Location = '13, 340' $btnUpdate.Name = "btnUpdate" $btnUpdate.Size = '75, 23' $btnUpdate.TabIndex = 1 $btnUpdate.Text = "Update" $btnUpdate.UseVisualStyleBackColor = $True $btnUpdate.add_Click($handler_btnUpdate_Click) # # lblPrompt # $lblPrompt.AutoSize = $True $lblPrompt.Location = '12, 9' $lblPrompt.Name = "lblPrompt" $lblPrompt.Size = '120, 13' $lblPrompt.TabIndex = 0 $lblPrompt.Text = "Enter a computer name:" $form1.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 OnApplicationLoad to initialize if((OnApplicationLoad) -eq $true) { #Call the form Call-ComputerPrompt_psf | Out-Null #Perform cleanup OnApplicationExit }