Use HTML form as GUI for powershell Use HTML form as GUI for powershell powershell powershell

Use HTML form as GUI for powershell


I was trying to accomplish the same thing and ran across your post. I see it's been about 8 months, but if you're still looking here's what I found. I was not able to get "onclick" to work. So I used a hidden input field, and defined an action for the button to update the value of that field. In powershell I getElementbyId for the hidden field, and use that to recognize the user has completed the input.

$html = @"<html><body><form>First name: <input type="text" id="firstname"><br>Last name: <input type="text" id="lastname"><br><input type="hidden" name="finished" value="0"><input type="button" id="button" value="Continue" onclick="finished.value=1"></form></body></html>"@$ie = new-object -com "InternetExplorer.Application"$ie.navigate2("about:blank")$ie.AddressBar  = $false$ie.MenuBar     = $false$ie.StatusBar   = $false$ie.document.body.innerHTML = $html$ie.Visible = $true$doc = $ie.documentwhile ($doc.getElementByID("finished").value -ne 1) {    start-sleep -m 500}$ie.Visible = $false"You answered:"$doc.getElementByID("firstname").value$doc.getElementByID("lastname").value$ie.quit()


The following article on Web UI automation with PowerShell may help you. http://msdn.microsoft.com/en-us/magazine/cc337896.aspx


I know you specified an HTML form but you might be better off writing a WinForms GUI for this instead.

http://www.techotopia.com/index.php/Creating_GUIs_in_Windows_PowerShell_1.0_with_WinForms