Is it possible to implement the following powershell script?
The purpose is to call the script blocks later to get the html controls.
$sites = @{
site1= @{
url = ".......";
inputUserID = { $doc.getElementsByID("username"]) }; #Some code to get the html input control
inputPassword = { $doc.getElementsByName("passowrd"]) }; #Some code to get the html input control
};
.....
}
$ie = New-Object -ComObject "InternetExplorer.Application"
$ie.navigate($sites[$site]["url"])
$ie.visible = $true
while ($ie.busy) { start-sleep -milliseconds 1000; }
... #Get the input controls and fill the values
The question has been updated. Is it clear enough? It shouldn’t be so hard to understand.
The way to get a closure from a scriptblock in PowerShell is to do this:
It’s hard to tell from the code above if this will help any, but it’s what you asked for.