完成后的UI 界面:

p_w_picpath

#以下为UI登陆框代码内容

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")    
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$objForm = New-Object System.Windows.Forms.Form    
$objForm.Text = "Reset Password"    
$objForm.Size = New-Object System.Drawing.Size(300,140) #此处是输入框的比例

$objForm.StartPosition = "CenterScreen"  
$objForm.KeyPreview = $True

$objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter")    
   {$username=$objTextBox.Text;$objForm.Close()}})    
$objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape")    
   {$objForm.Close()}})

$OKButton = New-Object System.Windows.Forms.Button  
$OKButton.Location = New-Object System.Drawing.Size(55,65) #指定OK按钮的位置    
$OKButton.Size = New-Object System.Drawing.Size(75,23) #指定按钮比例  
$OKButton.Text = "OK"    
$OKButton.Add_Click({$username=$objTextBox.Text;$objForm.Close()})#此处指定输入框中的变量    
$objForm.Controls.Add($OKButton)

$CancelButton = New-Object System.Windows.Forms.Button  
$CancelButton.Location = New-Object System.Drawing.Size(170,65) #指定Cancel按钮的位置    
$CancelButton.Size = New-Object System.Drawing.Size(75,23)  #指定按钮比例  
$CancelButton.Text = "Cancel"    
$CancelButton.Add_Click({$objForm.Close()})    
$objForm.Controls.Add($CancelButton)

$objLabel = New-Object System.Windows.Forms.Label  
$objLabel.Location = New-Object System.Drawing.Size(10,20) #此处是标头的位置    
$objLabel.Size = New-Object System.Drawing.Size(280,20)    
$objLabel.Text = "Please enter UserName:" #此处是指定标头的内容    
$objForm.Controls.Add($objLabel)

$objTextBox = New-Object System.Windows.Forms.TextBox    
$objTextBox.Location = New-Object System.Drawing.Size(10,40) #此处是指定输入框的位置    
$objTextBox.Size = New-Object System.Drawing.Size(260,20) #此处是指定输入框的比例大小    
$objForm.Controls.Add($objTextBox)

$objForm.Add_Shown({$objForm.Activate()})  
[void] $objForm.ShowDialog()