#------------------------------------------------------------------------ # Source File Information (DO NOT MODIFY) # Source ID: c29587bc-1a27-4f47-971a-6d169cf321bb # Source File: ..\Documents\SAPIEN\PowerShell Studio 2012\Files\XComputerName.pff #------------------------------------------------------------------------ #region File Recovery Data (DO NOT MODIFY) <#RecoveryData: YxEAAB+LCAAAAAAABAC9WFtvozgUfl9p/wPiOZuEkFulBKmh7aiadhoN2Zl5qwwcEm+NHRnTlvn1 a3NJIJCGVpOqUlUfzuFcvq+fbWbfwWPPwJMrJJD191+aNnvgeI0pIjeYwDcUgvXLZuE2FsDVqrsN glmv5pNGqtUP4BFm1DK6g1mvbMje7f4HntBEsoW57iSRgLD7E1OfvUTdG8bD7HdHa3rU0fJXzYfd vvrpaHZMRMxhTiEWHJGOtoxdgr2vkKzYE9C5O5mgkTcaGxfmEPrTC12jsti5Hsj3PThX5b50zdtg 4nMZpduMCs5IpKdFy7KXnG2BiyQPXyDvyWaEcd26Bx/HoUOQgAWJYdYrXI+E2gQDFQ7+Dbo1mIw6 mjEYnQxS7S8Y94E7IiEy8hujp1OlXVkNrZ6MdDbs5dZjVLduEIla+AvExZJFWGAVZMsOZakeB6An Y1dse88ioVsr3jS+62f5stz1jiG/saFH9WTWS32LwNNMu0MukLNTjags12ogbdlWn9Ed81A22slU MmZSG9Mx8JuTtwjPCGoMxh1tYLbwXyH3lvrwqlutvOFVAp7WpRWFac3M7GU4tkd1EQvB6NlhddM0 D1/fB2RJOL5sJOt/brBoA8eeABdmR5v2WxOgKLM15NP+uxE3WiPeqo5/I/iBoxiRVOtKE2vWogON kPrqPe37fkzXB9Lwbk6p6hfs9eykEjKPy16Nj6rDaNjRhm3Ay8hRpGuvB2PFjjbs27Oj0buMmBqu vUF0Df6+pMeS9Q30qovTQF5zzrgs5xnLvfTscILKts2zGccOEwpghKmS6BTpEtDfIQBJAg/eOrb0 doOpzLk6mssoglAWDVHhnVsSKx/CPaJoDaEcdPcyFixMKbUfhtl2GKbhBuZ0NEa+OR6CKQ83u0yH mcPIY5xg9w+M/I0sWX+fkeOPE+l0RnVq/5xEHL1guv5Irr4ZjIJJYBj+qI9MdDrXr5B8Tk+Yy38Q xhMH+DP24EOQvbs7m3H4lPbyrqQqyNbO0NtuWajKbCk3aykivKjoC0hZQ6S0S2QOuxtjrltN1tyo riF116pVShcOIBI2h1S11ImkZtt523Ek5a14Xnr3sQdLeblTymv9o3bKYrEX6Zg6q0u1z+V/7QPZ i7wGbYCQ4g4sr8R1YyHf1WnNHPBijuU2sRP4akDtvp2iWr9zF3uOH3ui5nxgP/Q/BKrJegWRx/G2 OuReo1VtXIgm5ZkfWmy2TThebyrA1G236u5AETkosNnc+LEiCzj+SFYW7k8dea1h+RxS+bDRK3Ff MqH8UeV/0SXwGmMRAAA=#> #endregion #======================================================================== # Code Generated By: SAPIEN Technologies, Inc., PowerShell Studio 2012 v3.1.24 # Generated On: 2014-05-07 13:18 # Generated By: administrator #======================================================================== #---------------------------------------------- #region Application Functions #---------------------------------------------- function OnApplicationLoad { #Note: This function is not called in Projects #Note: This function runs before the form is created #Note: To get the script directory in the Packager use: Split-Path $hostinvocation.MyCommand.path #Note: To get the console output in the Packager (Windows Mode) use: $ConsoleOutput (Type: System.Collections.ArrayList) #Important: Form controls cannot be accessed in this function #TODO: Add snapins and custom code to validate the application load return $true #return true for success or false for failure } function OnApplicationExit { #Note: This function is not called in Projects #Note: This function runs after the form is closed #TODO: Add custom code to clean up and unload snapins when the application exits $script:ExitCode = 0 #Set the exit code for the Packager } #endregion Application Functions #---------------------------------------------- # Generated Form Function #---------------------------------------------- function Call-XComputerName_pff { #---------------------------------------------- #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() $formOSDComputerName = New-Object 'System.Windows.Forms.Form' $labelEnterComputerName = New-Object 'System.Windows.Forms.Label' $buttonOK = New-Object 'System.Windows.Forms.Button' $textbox1 = New-Object 'System.Windows.Forms.TextBox' $errorprovider1 = New-Object 'System.Windows.Forms.ErrorProvider' $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' #endregion Generated Form Objects #---------------------------------------------- # User Generated Script #---------------------------------------------- $formOSDComputerName_Load={ #TODO: Initialize Form Controls here } $textbox1_TextChanged={ #TODO: Place custom script here } $buttonOK_Click={ #TODO: Place custom script here $errorprovider1.Clear() if ($textbox1.Text.Length -eq 0) { $errorprovider1.SetError($textbox1,"The filed can not be empty!") } else { if ($textbox1.Text.Length -gt 15) { $errorprovider1.SetError($textbox1, "Max 15 characters") } else { $ComputerName = $textbox1.Text $GetWmi = Get-WmiObject -Class Win32_ComputerSystem $GetWmi.Rename($ComputerName) $formOSDComputerName.Close() } } } # --End User Generated Script-- #---------------------------------------------- #region Generated Events #---------------------------------------------- $Form_StateCorrection_Load= { #Correct the initial state of the form to prevent the .Net maximized form issue $formOSDComputerName.WindowState = $InitialFormWindowState } $Form_Cleanup_FormClosed= { #Remove all event handlers from the controls try { $buttonOK.remove_Click($buttonOK_Click) $textbox1.remove_TextChanged($textbox1_TextChanged) $formOSDComputerName.remove_Load($formOSDComputerName_Load) $formOSDComputerName.remove_Load($Form_StateCorrection_Load) $formOSDComputerName.remove_FormClosed($Form_Cleanup_FormClosed) } catch [Exception] { } } #endregion Generated Events #---------------------------------------------- #region Generated Form Code #---------------------------------------------- # # formOSDComputerName # $formOSDComputerName.Controls.Add($labelEnterComputerName) $formOSDComputerName.Controls.Add($buttonOK) $formOSDComputerName.Controls.Add($textbox1) $formOSDComputerName.BackColor = 'MediumSlateBlue' $formOSDComputerName.ClientSize = '275, 125' $formOSDComputerName.FormBorderStyle = 'None' $formOSDComputerName.Name = "formOSDComputerName" $formOSDComputerName.ShowIcon = $False $formOSDComputerName.StartPosition = 'CenterScreen' $formOSDComputerName.TopMost = $True $formOSDComputerName.add_Load($formOSDComputerName_Load) # # labelEnterComputerName # $labelEnterComputerName.Location = '78, 17' $labelEnterComputerName.Name = "labelEnterComputerName" $labelEnterComputerName.Size = '126, 23' $labelEnterComputerName.TabIndex = 3 $labelEnterComputerName.Text = "Enter Computer Name" # # buttonOK # $buttonOK.BackColor = 'GhostWhite' $buttonOK.Location = '93, 80' $buttonOK.Name = "buttonOK" $buttonOK.Size = '80, 23' $buttonOK.TabIndex = 1 $buttonOK.Text = "OK" $buttonOK.UseVisualStyleBackColor = $False $buttonOK.add_Click($buttonOK_Click) # # textbox1 # $textbox1.Location = '54, 43' $textbox1.Name = "textbox1" $textbox1.Size = '160, 20' $textbox1.TabIndex = 0 $textbox1.add_TextChanged($textbox1_TextChanged) # # errorprovider1 # $errorprovider1.ContainerControl = $formOSDComputerName #endregion Generated Form Code #---------------------------------------------- #Save the initial state of the form $InitialFormWindowState = $formOSDComputerName.WindowState #Init the OnLoad event to correct the initial state of the form $formOSDComputerName.add_Load($Form_StateCorrection_Load) #Clean up the control events $formOSDComputerName.add_FormClosed($Form_Cleanup_FormClosed) #Show the Form return $formOSDComputerName.ShowDialog() } #End Function #Call OnApplicationLoad to initialize if((OnApplicationLoad) -eq $true) { #Call the form Call-XComputerName_pff | Out-Null #Perform cleanup OnApplicationExit }