Script Not working (help)

Hi, Can some one advise on the below script. I cant get this to work in a SCCM Task sequence (Does nothing just sits at a blank screen) and if i run it directly from PS ISE it loads but if i change it to show a msg box after ok is clicked i get nothing (Blank Responce) What i was hoping for was to when click ok, it takes the text inputed from the Textbox (example: X1W10) and the Type of Build from the selected Options (if Standard selected then S- if Admin selected A-) and then change the Hostname in Winpe Part of TS (example S-X1W10 or A-X1W10) and at the same time create a TS Variable for the build type so if Admin Selected create a Variable (Exable: AdminBuild or StandardBuild if Standard selected.) Sorry im new to powershell.

Scrip:

Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.Windows.Forms
[void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
[System.Windows.Forms.Application]::EnableVisualStyles()

# ---- Form Information ---- #
function Load-Build {
$Build.Controls.Add($TextBox1)
$Build.Controls.Add($RadioButton1) #Standard
$Build.Controls.Add($RadioButton2) #Admin
$Build.Controls.Add($Button1)
$Build.Controls.Add($Groupbox1)
$Build.Add_Shown({$Build.Activate()})
[void] $Build.ShowDialog()
}

$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'

$Build = New-Object system.Windows.Forms.Form
$Build.StartPosition = "CenterScreen"
$Build.SizeGripStyle = "Hide"
$Build.ControlBox = $false
$Build.Size = New-Object System.Drawing.Size(180,200)
$Build.MinimumSize = New-Object System.Drawing.Size(180,200)
$Build.MaximumSize = New-Object System.Drawing.Size(180,200)
$Build.text = "Build"
$Build.TopMost = $true

$TextBox1 = New-Object system.Windows.Forms.TextBox
$TextBox1.multiline = $false
$TextBox1.width = 135
$TextBox1.height = 20
$TextBox1.location = New-Object System.Drawing.Point(6,15)
$TextBox1.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$TextBox1.Text = ""

$RadioButton1 = New-Object system.Windows.Forms.RadioButton
$RadioButton1.text = "Standard Build"
$RadioButton1.AutoSize = $true
$RadioButton1.width = 104
$RadioButton1.height = 20
$RadioButton1.location = New-Object System.Drawing.Point(8,46)
$RadioButton1.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)

$RadioButton2 = New-Object system.Windows.Forms.RadioButton
$RadioButton2.text = "Admin Build"
$RadioButton2.AutoSize = $true
$RadioButton2.width = 104
$RadioButton2.height = 20
$RadioButton2.location = New-Object System.Drawing.Point(8,72)
$RadioButton2.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)

$Button1 = New-Object system.Windows.Forms.Button
$Button1.text = "OK"
$Button1.width = 130
$Button1.height = 30
$Button1.location = New-Object System.Drawing.Point(7,100)
$Button1.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)

$Groupbox1 = New-Object system.Windows.Forms.Groupbox
$Groupbox1.height = 140
$Groupbox1.width = 150
$Groupbox1.text = "Enter Computer Name"
$Groupbox1.location = New-Object System.Drawing.Point(5,10)

$Groupbox1.controls.AddRange(@($TextBox1,$RadioButton1,$RadioButton2,$Button1))
$Build.controls.AddRange(@($Groupbox1))

# ---- Main Code ---- #

# Determine last Part of the Computer Name
$ComputerName = "$($TextBox1.text)"
$ComputerName = $ComputerName.ToUpper()

# Determine first part of Build Selected
$Build_Type = ""
if ($radiobutton1.Checked -eq $true) { $Build_Type = "$($Build_Type)S-"; } # S = Standard
elseif ($radiobutton2.Checked -eq $true) { $Build_Type = "$($Build_Type)A-"; } # A = Admin

# Determine the Fill Computer Name
$OSDFullName = "$($Build_Type)$($ComputerName)"

# ---- Close Form Down Code ---- #

$Button1.Add_Click({

# Load TS Environment
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment

# Set Computer Name in TS
$TSEnv.Value("OSDComputerName") = "$OSDFullName"

# Set Build Type in TS
$TSEnv.Value($TSBuild) = $Build_Type

# Close Build
$Build.Close()
})

# ---- Show Form ---- #

$Build.ShowDialog()

The variables are not assigned values when the radio buttons are clicked or when the computer name box is filled in, some action is required to populate them. If you move this:

# —- Main Code —- #

# Determine last Part of the Computer Name
$ComputerName = “$($TextBox1.text)”
$ComputerName = $ComputerName.ToUpper()

# Determine first part of Build Selected
$Build_Type = “”
if ($radiobutton1.Checked -eq $true) { $Build_Type = “$($Build_Type)S-“; } # S = Standard
elseif ($radiobutton2.Checked -eq $true) { $Build_Type = “$($Build_Type)A-“; } # A = Admin

# Determine the Fill Computer Name
$OSDFullName = “$($Build_Type)$($ComputerName)”

into the $Button1.Add_Click({}) section, the variables will be populated when the OK button is clicked and your script should work as expected. I just added [System.Windows.Forms.MessageBox]::Show($OSDFullName) for testing.