I have a powershell script that I would like to run using an html form. All I have is a few form fields and a button. When I run my powershell script, it opens a new ie window
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 = @"
"@
$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.document
while ($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()