Making my first powershell website script

hi all,

ive made a PS script and it works when i run it via powershell normal method, ie open up powershell and type in the path of my script and i get the GUI, heres my script

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$unlabel = New-Object System.Windows.Forms.Label
$unlabel.Location = New-Object System.Drawing.Point(10,20)
$unlabel.Size = New-Object System.Drawing.Size(280,20)
$unlabel.Text = 'Please type in your username below:'

$unbox = New-Object System.Windows.Forms.TextBox
$unbox.Location = New-Object System.Drawing.Point(10,40)
$unbox.Size = New-Object System.Drawing.Size(260,20)

$oplabel = New-Object System.Windows.Forms.Label
$oplabel.Location = New-Object System.Drawing.Point(10,60)
$oplabel.Size = New-Object System.Drawing.Size(280,20)
$oplabel.Text = 'Please type in your old password below:'

$opbox = New-Object System.Windows.Forms.TextBox
$opbox.Location = New-Object System.Drawing.Point(10,80)
$opbox.Size = New-Object System.Drawing.Size(260,20)

$nplabel = New-Object System.Windows.Forms.Label
$nplabel.Location = New-Object System.Drawing.Point(10,100)
$nplabel.Size = New-Object System.Drawing.Size(280,20)
$nplabel.Text = 'Please type in your new password below:'

$npbox = New-Object System.Windows.Forms.TextBox
$npbox.Location = New-Object System.Drawing.Point(10,120)
$npbox.Size = New-Object System.Drawing.Size(260,20)

$domlist = New-Object System.Windows.Forms.ComboBox
$domlist.text = ""
@("robo84") | ForEach-Object {[void] $domlist.Items.Add($_)}
$domlist.SelectedIndex = 0
$domlist.Location = New-Object System.Drawing.Point(10,160)
$domlist.Size = New-Object System.Drawing.Size(260,20)

$submit = New-Object System.Windows.Forms.Button
$submit.Location = New-Object System.Drawing.Point(10,200)
$submit.Size = New-Object System.Drawing.Size(260,20)
$submit.Text = "Submit"
$submit.Add_Click({
$un = $unbox.text
$op = $opbox.text
$np = $npbox.text
$dom = $domlist.text
$dom1 = "dc01."+$domlist.text+".net"
write-host $un $op $np $dom1
Set-ADAccountPassword -Identity $un -OldPassword (ConvertTo-SecureString -AsPlainText "$op" -Force) -NewPassword (ConvertTo-SecureString -AsPlainText "$np" -Force) -server $dom1
})

$form = New-Object System.Windows.Forms.Form
$form.Text = 'Self Service Password Portal'
$form.Size = New-Object System.Drawing.Size(500,500)
$form.StartPosition = 'CenterScreen'

$form.Controls.Add($unlabel)
$form.Controls.Add($unbox)
$form.Controls.Add($oplabel)
$form.Controls.Add($opbox)
$form.Controls.Add($nplabel)
$form.Controls.Add($npbox)
$form.Controls.Add($domlist)
$form.Controls.Add($submit)
$form.Add_Shown({$form.Activate()})
$form.ShowDialog()

now how would i run this in powershell universal

thanks,
rob

Powershell Universal does not use windows forms so you cannot just run the above code in PSU.
Powershell universal has java script elements that wrap arround your code and thats what will be rendered to a web GUI.
for example if you want to create a textbox in PSU you will use the following code

New-UDTextbox -Id “PATH” -Icon (New-UDIcon -Icon ‘dropbox’) -Placeholder “Type Required Path” -Type text

with that said you need to build from scratch a form with elements like textbox , dropbox , button …etc using PSU components.

Ok thanks, got it

in that being said i would need to re write my whole script i might aswell try to write html code for it for the user input stuff ie labels/textbox/combobox and when they click submit button it runs/talks to powershell to run the powershell command to change the users password?