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